$.ajaxSettings.async = false;是什么意思?

部分摘自:https://blog.csdn.net/jin_tk/article/details/88872821

我们都知道$.post() 和 $.get()都是异步请求的方式,但有时候不得不用,但又要同步请求时,就用到了上面写的。

1方式1 2//设置为同步 3 $.ajaxSettings.async = false; 4 $.post("url", data, function(result) { 5 // 请求处理 6 },"json"); 7 //设置回异步 8 $.ajaxSettings.async = true;

使用第一种一定要注意:使用了同步后($.ajaxSettings.async = false;),及时释放掉,使用异步($.ajaxSettings.async = true;),不然会锁死资源,使得其他线程不能访问数据;

1方式22$.ajax({ 3 type: "post", 4 url: "url", 5 data: {"reportId": rows[0].reportId}, 6 async: false, 7 success: function(result){ 8 if (result.success){}else{} 9 } 10});

同步$.ajaxSettings.async = false;

异步$.ajaxSettings.async = true;

end;

点赞
收藏

评论区

加载中...

相关推荐

java实体 和 xml相互转换

参考:https://blog.csdn.net/LookForDream\_/article/details/88884316(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fblog.csdn.net%2FLookForDream_%2Farticle%2Fdetails

springcloud 服务间通讯方式 Ribbon

查看Ribbon:https://blog.csdn.net/qq\_32534855/article/details/84111188(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fblog.csdn.net%2Fqq_32534855%2Farticle%2Fdetails%2F

InsightFace源码以及pre

一下摘自:https://blog.csdn.net/Fire\_Light\_/article/details/79602705(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fblog.csdn.net%2FFire_Light_%2Farticle%2Fdetails%2F7960

MyBatis中的@Mapper注解及配套注解使用详解

https://blog.csdn.net/phenomenonstell/article/details/79033144(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fblog.csdn.net%2Fphenomenonstell%2Farticle%2Fdetails%2F790

(使用通过混淆+自己第三方保留成功混淆)AndroidStudio 混淆打包

原文:https://blog.csdn.net/mazhidong/article/details/64820838(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fblog.csdn.net%2Fmazhidong%2Farticle%2Fdetails%2F64820838)A

Git本地分支和远程分支关联

转载:https://blog.csdn.net/cherishhere/article/details/52606884(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fblog.csdn.net%2Fcherishhere%2Farticle%2Fdetails%2F52606884