PDA

View Full Version : auto refresh jsp page when data is updated in database



nischalinn
20 Jun 2012, 05:15 AM
I've a home.jsp (displays data in tabular form) which have a form which opens a pop up window to
update data (editUser.jsp).


<form method ="post" action="editUser.jsp" onsubmit="target_popup(this)">


editUser.jsp has a form to update data


<form method="post" action="edit.jsp">

/*HTML FORM*/

after clicking on submit button it goes to edit.jsp page to update data to the database. In the edit.jsp page
contains only java code for updating data and nothing else.

Now i've to auto refresh home.jsp page after the data is inserted to database or when the submit button is pressed in editUser.jsp? How can I do it?? Till now I've to manually refresh the page. Flow of web pages.


home.jsp ->editUser.jsp -> edit.jsp


$(function(){
$("#submit").click(function(){

var a=$("#ID").val();
var b=$("#NAME").val();
var c=$("#PWD").val();
var datastring='ID=' + a + '&NAME=' + b+'&PWD='+c ;

$.ajax
({
type: "POST",
url: "edit.jsp",
data: datastring,
success: function(){

window.close();
window.location.href="home.jsp";




}
});


});
});

but this code is not working. How can I do it????