tags:

views:

37

answers:

1

hello all,

i m using Jquery ajax post method to edit a form on same page, but if there is some mistake then how do i send user back on that page where data were loaded.

now i describe u what i do?

i have a page manageMovies.php there are list of movie name, now when i click on a name of any movie, then i load editMovie.php on same page now when i do some mistakes( i.e when validations fails) then i want to go back on same page manageMovies.php loaded with editunit.php regarding that movie on the page.

here is my page structure

manageMovies.php

<div id="display"></div>
<div id="movieList">
  <table >
        <tr><td id="mov_10">Apharan</td></tr>
        <tr><td id="mov_11">Gangaajal</td></tr>
        <tr><td id="mov_12">Rajniti</td></tr>
  </table>
</div>
<script type="text/javascript">
 jQuery('td').click(function () {
        jQuery('#movieList').hide(); // hide the  div 'movielist'
        jQuery.post('editMovie.php', {
            idForEdit: jQuery(this).attr('id')
        }, function (data) {
           jQuery("#display").html(data); //display the editMovie.php page on 'display' div
        });
    });
</script>

now when i do some mistakes on editunit.php and go further for post, then i need to go back on same page (manageMovies.php) where editMovie.php is shown on display div and movielist div should be hidden

A: 

I think you need to use JSON data. For example when you click button "edit", you go to edit page. Inside the page we have ID of record. Now we can load JSON data of your object from your php script. And "onPost" if you get error, you can just run reinit function and load again "clean" data for you model.

Saff