Ajax Browser Feedback Button

I know that there are a lot of topics on this, but I could not determine what to do on the basis of what I read in other topics.

I have a page "abc.php". The user can perform a search, which then fills out the form with two ajax requests. Then, if the user goes to another page and then clicks BACK on "abc.php", the contents of the form will not be completed, since ajax does not start. Is there any way to do this?

+4
source share
3 answers

Change your url when you do ajax by adding search terms there after the hash (e.g. http://example.com/search.php#search-terms-here )

Then, when the page is loaded, read the search terms from the URL.

+4
source

This is a very good article / tutorial on enabling back button using jQuery.

+1
source

Using history.js , the following function β€œlistens” for changes in the url string and calls the function to load the corresponding page:

 History.Adapter.bind(window,'statechange',function(){ var State = History.getState(); page(State.url); }); function page(url) { //AJAX } 

Now, when you want to change the page, you call:

 History.pushState({state:X}, "Page Title", "Page Url"); 

This will update the browser url string and automatically call up the page (State.url) for the new URL; and all browser functions, such as the forward / back button, bookmarks, etc., should work.

+1
source

Source: https://habr.com/ru/post/1344773/


All Articles