Is there a way to go back in history only for ajax calls ?
I'm looking for a history back button that only works for ajax calls on the current page.
So the button should not have the power to leave the page as we know it from browser back button.
Is there a way to go back in history only for ajax calls ?
I'm looking for a history back button that only works for ajax calls on the current page.
So the button should not have the power to leave the page as we know it from browser back button.
You can use the History API for this.
Basically what you are doing is calling history.pushState()
when doing an AJAX call and listening for the popstate
event on the window
object. But the logic that will manipulate your DOM to show the last state will have to be implemented by yourself.