页面按钮:
<button id="song">abort</button>
请求:
1 var str = {} 2 str.xhr = $.ajax({ 3 type: ‘get‘, 4 url: ‘http://xxx.xxx.xxx.x:9202/performance/getPerformanceRankList?phone=13544511617&locale=zh&gridRank=1001&sortColumn=&order=&page=0&pageSize=10&queryStr=&_=1565081256257‘, 5 success: function () {} 6 }); 7 str.xhr1 = $.ajax({ 8 type: ‘get‘, 9 url: ‘http://xxx.xxx.xxx.xx:9202/performance/getPerformanceRankList?phone=13544511617&locale=zh&gridRank=1001&sortColumn=&order=&page=0&pageSize=10&queryStr=&_=1565081256257‘,10 success: function () {} 11 }); 12 str.xhr2 = $.ajax({ 13 type: ‘get‘,14 url: ‘http://x.xx.xxx.x:9202/performance/getPerformanceRankList?phone=13544511617&locale=zh&gridRank=1001&sortColumn=&order=&page=0&pageSize=10&queryStr=&_=1565081256257‘,15 success: function () {} 16 }); 17 console.log(str.xhr,str.xhr1,str.xhr2);
执行 结束ajax请求,并发送新的请求:
1 $("#song").click(function () { 2 Abort(str) 3 setTimeout(function () { 4 str.xhr3 = $.ajax({ 5 type: ‘get‘, 6 url: ‘http://xxx.xx.xx.xx:9202/performance/getPerformanceRankList?phone=13544511617&locale=zh&gridRank=1001&sortColumn=&order=&page=0&pageSize=10&queryStr=&_=1565081256257‘, 7 success: function () {} 8 }); 9 },500) 10 })
结束ajax请求的方法:
function Abort(str) { for(var i in str){ str[i].abort(); } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。