• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

calling jsp page using Jquery

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have this code snippet where I am passing data to another jsp file. and in Ajax.jsp , my code is . Now when I click on text box in index.jsp, I am getting alert promt saying data has been saved. but when I display Ajax.jsp the value is null. My doubt is , am I really passing data to another jsp ? Am I wrong in code ? Please correct me.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's start by cleaning up the basics.

If you are using jQuery, what with: onclick="javascript:getInput()" ? Use jQuery to set up event handling. ALos, never use the javascript: prefix when not using jQuery.

Your JSP does not create valid HTML. Is it supposed to?
 
jazy smith
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,

so what could be the way if I want to use the same two code and want to pass parameter to another jsp using same jquery function. From your reply what I understood is , I have to create event handler. Any help or link you can provide to run this simplest example. ( i want to use same jquery ajax function and want to pass data to another jsp )

thanks in advance,
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the code, that will do..........


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#click").click(function(){
name=$("input#name").val();
age=$("input#age").val();
$.ajax({
type:"POST",
url:"jsp/pageTwo.jsp",
data:"name="+name+"&age="+age,
success:function(data){
$("#response").html(data);
}
});
});
});
</script>
</head>
<body>
Name: <input type="text" id="name" name="name"><br/><br/>
Age  : <input type="text" id="age" name="age"><br/><br/>
<button id="click">Click Me</button>
<div id="response"></div>
</body>
</html>
 
reply
    Bookmark Topic Watch Topic
  • New Topic