aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes calling jsp page using Jquery Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "calling jsp page using Jquery " Watch "calling jsp page using Jquery " New topic
Author

calling jsp page using Jquery

jazy smith
Ranch Hand

Joined: Nov 18, 2009
Posts: 101
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61747
    
  67

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
jazy smith
Ranch Hand

Joined: Nov 18, 2009
Posts: 101
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,
Ganesh Ravi Kumar
Greenhorn

Joined: Dec 06, 2010
Posts: 17
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>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling jsp page using Jquery