I have an ajax function that performs a filter and then changes the url.
How would I do the equivalent of the following:
$(window.location).change(function() {
alert('hello');
})
I have an ajax function that performs a filter and then changes the url.
How would I do the equivalent of the following:
$(window.location).change(function() {
alert('hello');
})
You would probably have a look at the history API. You can use the onhashchange
event to detect that change.
$(window).on('hashchange', function() {
alert('hello');
});
If you change location, browser stop all of script and don't trigger change function, you can use only unload event of document when use change the location, check it here http://api.jquery.com/unload/ and if you only change bookmark then only handle hashchange
event, you can find sample jquery plugin here http://benalman.com/projects/jquery-hashchange-plugin/..