I am trying to make a quick AJAX call before a user leaves a webpage. The event on fired in all browsers, but the call to webservic only completes in IE9 and FF10. Chrome, Safari, and Opera all fire the event but seem to kill the ajax call before it can
be made. Ive set jQuery's Ajax property 'async' to false, but that still doesnt seem to help. Any suggestions? I am using the event code below:
jQuery(window).on("unload", function() {
SendLastUpdate();//makes ajax call with async property set to false
});
gdogg
Member
54 Points
42 Posts
Calling webservice from unload event
Feb 29, 2012 08:23 PM|LINK
I am trying to make a quick AJAX call before a user leaves a webpage. The event on fired in all browsers, but the call to webservic only completes in IE9 and FF10. Chrome, Safari, and Opera all fire the event but seem to kill the ajax call before it can be made. Ive set jQuery's Ajax property 'async' to false, but that still doesnt seem to help. Any suggestions? I am using the event code below:
jQuery(window).on("unload", function() { SendLastUpdate();//makes ajax call with async property set to false });Specs
Member
618 Points
152 Posts
Re: Calling webservice from unload event
Feb 29, 2012 08:28 PM|LINK
In your ajax call, specify the async property to false to make the call synchronous
gdogg
Member
54 Points
42 Posts
Re: Calling webservice from unload event
Feb 29, 2012 08:47 PM|LINK
as I stated, i had already tried that, as that seemed to be the solution around the net. It made it work for IE and FF, but not in Chrome or Safari.
Specs
Member
618 Points
152 Posts
Re: Calling webservice from unload event
Feb 29, 2012 09:04 PM|LINK
Sorry about that, read your post too quickly.
Can you please post your ajax call code?
BU XI - MSFT
All-Star
22367 Points
2704 Posts
Microsoft
Re: Calling webservice from unload event
Mar 06, 2012 03:25 AM|LINK
Hello
It does not work accross browsers. One way you may walk around is to use an alert() box comes up after your ajax call codes. See if it works.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework