There is a problem with the "back" button of the browser and my application. The webapp uses ajax and standart requests. That all happens this way:
I make GET request to
list.jsp
page - it's the first page you see in application if you check the temp link I provided below. Now we are on Page 1 (the whole page was reloaded)I make Ajax request (click on link - i.e. page number) to page
4
. Only the parth of page was reloaded - everything is OK. Thus now we are on page 4I make Ajax request (click on link - i.e. page number) to page
5
. Only the parth of page was reloaded - everything is OK. Thus now we are on page 5Now I press the browser "back" button (one step back to history) - nothing happened. The browser consoles does not show any changes.
This step I press the browser "back" button again. It turns out that this step executed correctly. GET request happened.
What is going on? Why does the browser not remember changes that hapaned on step 3 ? How can I instruct the browser to make step back to history
to the changes that was made by ajax request?
You can check it online by temp link. Just try to go throuh the pages. The pink square is current page indicator.
update 1:
This code initialized after loader finished loading recources.
$(function() {
$(window).on('hashchange', refreshByHash);
refreshByHash();
function refreshByHash() {
var hash = window.location.hash;
console.log("hash = " + hash.substring(1));
/* $.ajax({
url : 'paginator.action?page=' + hash, // action
type : 'GET', //type of posting the data
dataType : 'html',
async: true,
success : function(htmlData) {
$('#paginator').html(htmlData);
},
error : function(xhr, ajaxOptions, thrownError) {
alert('An error occurred! ' + thrownError);
},
}); */
}
});