大佬教程收集整理的这篇文章主要介绍了jquery – Ajax是否在Firefox中正确实现?同步问题,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
// first ajax call,Note: this is asynchronous. $.ajax({ url: "/rest/someUrl",async : true,dataType : "json",contentType: "application/json",success : function(data) { console.log("async ajax call: success"); },error : function(data) { } }) // second ajax call,Note: this is synchronous. $.ajax({ url: "/rest/someUrl",async : false,success : function(data) { console.log("sync ajax call: success"); },error : function(data) { } })
在规范中,我没有发现任何引用,只要同步请求没有完成,所有脚本都应该停止执行(请注意,当sync-XHR启动时,async-XHR已经在运行).
但我发现了这个:
> Each XMLHttpRequest object has its own task source. Namely,the XMLHttpRequest task source.
– 两个请求代表一个任务源 –
> When a user agent is to queue a task,it must add the given task to one of the task queues of the relevant event loop. […] tasks from different task sources may be placed in different task queues.
– 任何任务都可以添加到同一个任务队列中,但不能 –
> An event loop must continually run through the following steps for as long as it exists:
1.Run the oldest task on one of the event loop’s task queues,if any,[…]. The user agent may pick any task queue.
– 他现在选择他在同步请求上放置的任务队列
当我没有误解这一点,并且我的逻辑没有错时,这可能会继续:
Firefox将两个XHR放在同一个队列中,IE和chrome将它们放在不同的任务队列中.
所有浏览器现在都运行任务队列,放置同步XHR.
>在IE和chrome中,同步XHR是其队列中最早的任务并运行
>在FF中,异步XHR是队列中最早的并且运行
两种实现似乎都是正确的.
以上是大佬教程为你收集整理的jquery – Ajax是否在Firefox中正确实现?同步问题全部内容,希望文章能够帮你解决jquery – Ajax是否在Firefox中正确实现?同步问题所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。