I have the following code alternatives, neither of which is satisfactory. I’m using jQuery 1.7.2
The first one is perfect in Firefox but in IE9 it posts but does not complete the action to write to the database. I have tried to make it ASYNC false as others have suggested but strangely that does not seem to make any difference. It may not work in other browsers as well.
The second one does complete but pops up a confirm close page dialog. I have seen suggestions about how to stop that but I could not achieve the same result.
Can anyone offer me an alternative? Or give me correct ASYNC false code that works for IE9 with the first one? Or show me how to correctly prevent the confirm close?
// Sends the post but does not complete the post in IE9
jQuery(window).unload(function() {
jQuery.post(
MyAjax.ajaxurl, etc
// works in IE 9 but throws up a confirm dialog box
jQuery(window).bind("beforeunload", function() { ...
jQuery.post(
MyAjax.ajaxurl, etc
Just don’t post every time a jQuery(window).scroll is triggered. Post only when a user stopped scrolling. Like this:
And a live example – http://jsfiddle.net/AJnk4/