Jquery AJAX 同步和长时间运行的请求
我使用 jQuery 循环遍历一个大表(1,000 行),并为每一行进行 AJAX 调用来处理一些信息并更新数据库。完成整个过程大约需要 30 分钟,我使用 jQuery UI 进度条来提供处理状态的可见性。
我希望能够启动其中几种类型的长时间运行的进程,但我发现这些后续的 AJAX 进程似乎一直在排队,直到上一个长时间运行的请求完成。
我在这个论坛上读到过有关浏览器限制并发 AJAX 会话数量的信息,所以这可能就是我在这里遇到的问题。我很好奇其他人如何处理运行这些类型的长时间运行的 AJAX 调用。
等待 30 分钟才能启动下一个 AJAX 请求对我来说并不起作用:)
I am using jQuery to loop through a large table (1,000 rows) and for each row I make an AJAX call to process some information and update a database. It takes roughly 30 minutes to complete this entire process and I use a jQuery UI progress bar to provide visibility into the processing status.
I'd like to be able to launch several of these types of long-running processes but am finding that these subsequent AJAX processes seem to be queued until the previous long-running request is complete.
I've read on this forum about browsers limiting the number of concurrent AJAX sessions so this may be what I'm up against here. I'm curious to learn how others address running these types of long-running AJAX calls.
Waiting for 30-minutes before I can launch my next AJAX request doesn't really work for me :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您需要对同一服务器发出大量请求,则必须使用子域。例如,不要仅将
www.domain.tld
指向您的应用程序,而是将*.domain.tld
指向它(或任何其他通配符子域)。发出 AJAX 请求时,只需使用.domain.tld
作为主机即可规避最大值。每个服务器的连接数限制。另一种解决方案是发送短时间运行的请求,该请求仅启动您的长时间进程,并保留一个长时间运行的 AJAX 请求,该请求将响应任何的状态更新 em> 您正在运行的进程。
If you need lots of requests to the same server, you'll have to use subdomains. For example, instead of just pointing
www.domain.tld
to your application, point*.domain.tld
to it (or any other wildcard subdomain). When making your AJAX requests, simply use<randomstring>.domain.tld
as the host to circumvent the max. connections per server limit.Another solution would be sending short-running requests which just start your long processes an keep one long-running AJAX request which will respond with status updates to any of your runing processes.