Trying to send AJAX POST on form submit. Already have a code working in all browsers except IE.
Working code (except IE)
$('form').one("submit", function(e) {
$.ajax(
{
url : url,
type: "POST",
data : data,
async: false,
complete: function() {
return true;
}
});
});
Tried almost everything I can, like onunload and onbeforeunload, and obviously the general onsubmit (both native Javascript and jQuery methods). But IE won't wait for AJAX calls to finish and loads the form action page.
onbeforeunload would make it wait, but bring a dialogue confirmation box (which I am not willing to show).
Also, async:false doesn't work on IE. I can't use HTTPRequest as the request is cross domain. Again, XDomainRequest is asynchronous, so even that is not useful.
Other ways, like event.preventDefault() won't submit the form after callback.
Note: The form on the page is submitted after successful validation with native submit function. I can't mess that code because it belongs to our client, and we are loading our code asynchronously.
Already checked links: using onbefore unload onbeforeunload with timeout