1

Im trying to fire off an AJAX request before a page unloads using the unlaod event and jQuery:

jQuery(window).on("unload", function(event) {        
     SaveSettings();//makes an ajax request with the 'async' property set to false
});

This works fine in IE9 and FF10, but in the webkit browsers (chrome and safari specifically), the event is called, but the AJAX request is never completed. I am setting jQuery's AJAX call to synchronous (i realise this may "hold up" the browser but it should be quick!). I even tried binding directly to the window.onbeforeunload event, but with the same results. I would think that a synchronous request to a webservice should prevent the browser from closing before the call is complete, right?

Mike_G
  • 16,237
  • 14
  • 70
  • 101
  • See this: http://stackoverflow.com/questions/276660/how-can-i-override-the-onbeforeunload-dialog-and-replace-it-with-my-own I don't think it is as easy and you'd think – aknosis Feb 28 '12 at 19:48
  • Ive read it, i cant seem to get it to work. Whats funny is that for some reason i want to say it used to work till I updated Chrome. – Mike_G Feb 28 '12 at 20:08

0 Answers0