I have written a JavaScript function that asynchronously calls a web service using XmlHttpRequest. I have been asked to make this function finish its work before the page is
XMLHttpRequest
support abort
method, you can get more details about it here: http://www.w3.org/TR/XMLHttpRequest/#the-abort-method
But you need to check how many browserы support it. For example, abort
was introduced in Windows Internet Explorer 7 and above.
Before or after calling send()
method of XMLHttpRequest
object you can setup a timer for n-seconds delay which will interrupt an asynchronous operation which is in progress.