Go back to page and update data

Asked

Viewed 1,288 times

1

I have a screen that lists my products. To register a new product, open another screen to enter the data and so register, on this same screen I have a back button, in it I have the code onClick="history.back()", but when it comes back to the list of products, that product that I just registered does not list, only lists when I do a new search. Is there any way to go back and update the list? Something like, history.back() + location.reload().

  • Since you’re working with PHP, why don’t you try creating a header("Location: suaURL"). Thus, the code will automatically return it to the previous page.

  • On the back button?

  • Is the back button necessary? The way I indicated, after INSERT in PHP, would be redirected automatically.

  • But I do the Insert with ajax

  • Any other suggestion?

  • Could you put some code (the one on the list of products) so we can visualise best, see how pupulated this list is!

Show 1 more comment

2 answers

3

I entered the solution in another forum, follow the link

Solution

<script type='text/javascript'>

(function() {
   if( window.localStorage ) {

      if( !localStorage.getItem( 'firstLoad' ) ) {
         localStorage[ 'firstLoad' ] = true;
         window.location.reload();

      } else {
         localStorage.removeItem( 'firstLoad' );
      }
   }
})();

1


Try to replace the method history.back() for Location.replace('sua_pagina_anterior.php').

If this does not solve it is because the logic of the homepage is not adequate or the script triggered by AJAX is not doing the insertion. (because you didn’t post the code and we can only assume).

If the problem persists, don’t feel compelled to ask +

Browser other questions tagged

You are not signed in. Login or sign up in order to post.