简体   繁体   English

如何优先排队Jquery Ajax请求

[英]How to queue Jquery Ajax request with priority

I have a web page with multiple ajax request to load SVG preview pictures. 我有一个带有多个ajax请求的网页来加载SVG预览图片。 On the same page I have some buttons that use ajax to load content used by jquery dialog. 在同一页面上,我有一些按钮使用ajax来加载jquery对话框使用的内容。

My problem is that loading time of jquery dialog is too long because others requests are not finished. 我的问题是jquery对话框的加载时间太长,因为其他请求没有完成。

I would like to know if it is possible to cancel all request in order to send the priority request and when it's done I resend the others ? 我想知道是否可以取消所有请求以发送优先级请求,一旦完成,我重新发送其他请求?

When the page is ready, the request to load SVG are send. 页面准备就绪后,将发送加载SVG的请求。 If user click on a button to load a dialog, the request for load content of the dialog must be executed in priority. 如果用户单击按钮以加载对话框,则必须优先执行对话框的加载内容请求。

Thanks for your help 谢谢你的帮助

Here's an example of a jQuery priority queue plugin: 这是一个jQuery优先级队列插件的示例:

http://benalman.com/code/projects/jquery-message-queuing/docs/files/jquery-ba-jqmq-js.html http://benalman.com/code/projects/jquery-message-queuing/docs/files/jquery-ba-jqmq-js.html

or for maintaining a list of pending calls / callbacks Or nesting the next call in the previous callback, you can have a look at IO 或者用于维护挂起的呼叫/回调列表或者在上一个回调中嵌套下一个呼叫,你可以看看IO

https://developer.yahoo.com/yui/3/io/#queue https://developer.yahoo.com/yui/3/io/#queue

Also there is a brilliant answer explained Sequencing ajax requests 还有一个很好的答案解释了测序ajax请求

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM