沉睡个人博客
沉睡个人博客
博客
工具箱
留言板
沉睡个人博客
博客
工具箱
首页
前端
【jquery】for循环中嵌套异步请求导致顺序错乱
【jquery】for循环中嵌套异步请求导致顺序错乱
756人已阅读
时间:2022-03-19 00:00:00
### for循环中嵌套异步请求导致顺序错乱 //for中嵌套异步时,执行顺序会混乱 for(var i=0; i<5; i++){ (function(j){ setTimeout(function(){ console.log("第"+(j+1)+"次循环"); }, Math.random() * 3000); }(i)); } 主要代码 (function(j){ }(i));
上一篇:【PHP】使用 file_get_contents 获取网站信息报错failed to open stream: HTTP request failed!
下一篇:【PHP】php7链接数据库报错The server requested authentication method unknown to the client