$.ajaxSetup({
headers:{'access_token':token},
timeout:1000,
complete:function(XMLHttpRequest,status){
if(status == "timeout"){
layer.alert("请求超时!")
}
}
})
终止ajax请求 .abort()
var ajaxtimeout = $.ajax({
url:url
headers:{'access_token':token},
timeout:1000,
complete:function(XMLHttpRequest,status){
if(status == "timeout"){
layer.alert("请求超时!")
ajaxtimeout .abort()//阻止请求
}
}
})