0

Im struggling with Ajax Deep linking and wonder if is possible to make an Ajax call when user click on Browser refresh button.

I tried to use beforeunload It works but still make a request to the server after the ajax call Is there a way to prevent the request to the server ?

    $(window).on('beforeunload',function(e){
        //ajax call here.          
    });
Merlin
  • 4,907
  • 2
  • 33
  • 51

1 Answers1

2

There is no hook into knowing when a user clicks refresh. From a browser perspective they are simply navigating away from the page. You could hook into the onbeforeunload method to do something...

window.onbeforeunload = function(){ return 'Testing...' }
xspydr
  • 3,030
  • 3
  • 31
  • 49
  • I have edited my question. Is there a way to prevent the request to the server after the Ajax Call. – Merlin Jan 10 '14 at 18:54