18910140161

jq停止/结束多个ajax请求

顺晟科技

2021-06-16 10:34:03

222

页面按钮:

按钮id='歌曲'中止/按钮

请求:

//www.oicqzone.com代码片段

1 var str={}

2 str.xhr=$ .ajax({

3 type: 'get ',

4 URL : ' http://XXX。XXX。XXX。x :9202/performance/get performance ranklist?phone=13544511617 locale=Zhgridrank=1001 sort column=order=page=0 page size=10 query str=_=1565081256257 ',

5 success: function () {}

6 });

7 str.xhr1=$ .ajax({

8 type: 'get ',

9 URL : ' http://XXX。XXX。XXX。XX :9202/performance/getperformance ranklist?phone=13544511617 locale=Zhgridrank=1001 sort column=order=page=0 page size=10 query str=_=1565081256257 ',

10 success: function () {}

11 });

12 str.xhr2=$ .ajax({

13 type: 'get ',

14 URL : ' http://x . xx。XXX。x :9202/performance/get performance ranklist?phone=13544511617 locale=Zhgridrank=1001 sort column=order=page=0 page size=10 query str=_=1565081256257 ',

15 success: function () {}

16 });

17 console.log(str.xhr,str.xhr1,str。xhr 2);

//www.oicqzone.com代码片段

执行结束创建交互式、快速动态网页应用的网页开发技术请求,并发送新的请求:

//www.oicqzone.com代码片段

1美元(' #song ').click(function () {

2中止(字符串)

3 setTimeout(函数(){

4 str.xhr3=$ .ajax({

5 type: 'get ',

6 URL : ' http://XXX。xx。xx。xx :9202/performance/get performance ranklist?phone=13544511617 locale=Zhgridrank=1001 sort column=order=page=0 page size=10 query str=_=1565081256257 ',

7 success: function () {}

8 });

9 }, 500)

10 })

//www.oicqzone.com代码片段

结束创建交互式、快速动态网页应用的网页开发技术请求的方法:

函数中止(str) {

for(var i in str){

str[i].abort();

}

}

我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航