detanx
设置timeout的时间,通过检测complete时status的值判断请求是否超时,如果超时执行超时的操作。

$.ajax({   url:\'\',   timeout : 1000, //超时时间设置,单位毫秒   type : \'get\',   data :{},   dataType:\'json\',   success:function(response){     alert(response);   },   complete : function(XMLHttpRequest,status){    if(status === \'timeout\'){//超时,status还有success,error等值的情况      ajaxTimeoutTest.abort();       alert("请求超时"); }   } });

  

 

分类:

技术点:

相关文章:

  • 2021-08-07
  • 2021-08-07
  • 2021-08-07
  • 2021-08-07
  • 2021-08-07
  • 2021-08-29
  • 2021-08-07
  • 2021-04-04
猜你喜欢
  • 2021-09-11
  • 2021-08-07
  • 2021-09-21
  • 2021-09-11
  • 2021-08-07
  • 2021-08-07
相关资源
相似解决方案