Using the back button, AJAX results were lost

So, I created a pagination system similar to Twitter, which shows 20 results, and the user can click the link to show the next twenty or all results. The number of displayed results can be controlled by the parameter at the end of the URL, however this is not updated using AJAX, therefore, if the user clicks on one of the results and then decides to return, he should start with only 20 results.

It seemed to me that if I update the URL when I pull results using AJAX, I should hopefully allow users to move back and forth without losing the number of results.

Is this possible, or am I completely mistaken?

Also, how can I change the URL? I have a way to edit the url using javascript and have its variable, but I'm not sure how to apply this variable to the url.

Any help here would be great!

Note: I am using the jQuery load () function to execute all of my AJAX.

+3
source share
5 answers

You cannot change the url of a page with javascript without reloading the page.

You can use cookies instead. By setting a client cookie, you can “remember” how many results the user likes to see.

Good javascript cookie page.

+1
source
+3

, :

+2

, :

, , , , , hashchange ajax, :

+1

3 google :


I will eat my shorts if none of them are useful. ^^

And yes - you cannot change the URL via JS.

-3
source

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


All Articles