0

I've a home.jsp (displays data in tabular form) inside 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.control flow of webpages

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????

4

1 回答 1

0

您可能有兴趣为您的用例实现类似Knockout的功能。它是一个 Javascript MVVM 框架,支持可观察对象,可在服务器更改时在客户端自动刷新。这样,您就不必进行硬页面刷新/重新加载。

于 2012-06-20T09:52:48.607 回答