weixin_33739646 2015-07-08 13:01 采纳率: 0%
浏览 34

超时事件中止XHR

I want to abort XHR request on timeout event, but it's not working. Syntax is next:

var req = new XMLHttpRequest();
req.open('POST', url , true);

req.timeout = 5000;
req.ontimeout = function () {
  req.abort();
};

So if XHR request is not finished in 5 seconds code should abort request. If I only write req.abort(), XHR request will perform.

  • 写回答

0条回答 默认 最新

    报告相同问题?