Failed to load resource: net::ERR_NETWORK_IO_SUSPENDED

前端 未结 2 443
攒了一身酷
攒了一身酷 2020-12-24 00:52

I searched Stack Overflow and Google for the specific error message in the title, but I did not find it (in the context of JavaScript coding, not browser settings). On my si

2条回答
  •  春和景丽
    2020-12-24 01:19

    Just summarizing my comments under the question for community.

    After some testing, it seems, that setting Ajax timeouts for every call is a must. Without timeouts, NET:: errors such as ERR_NETWORK_IO_SUSPENDED, ERR_INTERNET_DISCONNECTED, etc will cause Ajax to stop execution, and would not resume after computer wake up.

    For jQuery:

    $.ajax({
       url: yourURL,
       timeout: 4000
    });
    

    For XMLHttpRequest (XHR):

     xhr.timeout = 4000;
    

    Moreover, an exception handler is necessary for your script to catch connection errors, so that your JavaScript code would not break down because of unexpected behavior/values.

    Even with timeouts and exeption handler, your application will throw NET:: errors, but they would not harm your application; you could think of them as Notices.

提交回复
热议问题