I need to call the jquery ajax() function before a window unloads. In my case its a POST and I dont care about the return result, I just want a database to be updated.
So the answer seems to be to bind a function to the unload event, i.e. use the jquery unload() function, and that function makes an ajax call. In addition, I know you are supposed to add the synchronous parameter to the call. In other words, add async: false to the jquery ajax() call.
However, I have tried all this and it does not work on IE8! I have tested it many times and it simply will not work on IE8. Works fine in Firefox and Chrome.
Even stranger is that after I close the whole IE8 application, it seems as if then the call goes through! Is it being cached?
So other people are suggesting to bind the ajax beforeunload using jquery bind(). However there seems to be some mixed answers on whether this will work on all browsers.
I have not yet tried the beforeunload as this seems like the "hack" way of doing it. However, if it works then I dont really care as long as it does work.