How to implement history plugin for prototypejs?
-
27-10-2019 - |
Question
I am using AJAX with prototypejs. Now I want to use browser's back/forward button to redirect to already visited AJAX links. I found this plugin but I don't know which file I have to include in my project and from where to start. I am using following prototypejs code for AJAX requests with JSON response.
function ajaxRequest(url) {
parent.location.hash = url;
new Ajax.Request( url, {
method: 'get',
onSuccess: function( transport ) {
// get json response
var json = transport.responseText.evalJSON( true );
for(var id in json) {
$(id).innerHTML = json[id];
}
},
onFailure: function() {
alert('Error with AJAX request.');
}
});
return false;
}
Any idea ?
Thanks
Solution
You can use Really Simple History. You route your ajax calls through a hidden iframe that in-turn calls them from the parent page. When the user presses BACK it makes the iframe go back, therefore executing the prior ajax call.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow