Is it possible to abort a synchronous XmlHttpRequest?

前端 未结 4 1862
渐次进展
渐次进展 2021-01-19 01:35

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

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-19 01:43

    It is possible in IE.Use the timeout property.

    the code below worked for me

    xmlhttp.open("method","url",false);
    xmlhttp.timeout="time in ms";
    xmlhttp.ontimeout=function(){};
    xmlhttp.send();
    

提交回复
热议问题