如何在不挂断的情况下处理大量的ajax查询?

时间:2021-06-26 16:56:35

I am processing a csv file to import each rows in a Database.

我正在处理一个csv文件来导入数据库中的每一行。

For each row, I've got to ask Google Maps API to get its latitude and longitude coordinates so I can take some milliseconds for each row.

对于每一行,我都要求Google Maps API获取其纬度和经度坐标,以便每行可以花费几毫秒。

To give some feedback to the user, I choose to add each row with an AJAX POST request to the server API in order to check the validity for each row and give some progression feedbacks.

为了向用户提供一些反馈,我选择向服务器API添加带有AJAX POST请求的每一行,以检查每行的有效性并提供一些进度反馈。

My problem is that AJAX means asynchroneous and every request is sent at the same time without waiting for the answer.

我的问题是AJAX意味着异步并且每个请求都是在不等待答案的情况下同时发送的。

When more than 5 request are sent in the same time, the server returns 500 HTTP Error.

当同时发送超过5个请求时,服务器返回500 HTTP错误。

How is it possible for me to delay each request in order to wait until the previous one is returning before to send the next one ?

我怎么可能延迟每个请求,以便等到上一个请求返回之前发送下一个请求?

I am using JQuery ajax $.post() function to send each request.

我正在使用JQuery ajax $ .post()函数发送每个请求。

Thanks for your help

谢谢你的帮助

1 个解决方案

#1


0  

You could use the Ajax Queue plugin.

您可以使用Ajax Queue插件。

#1


0  

You could use the Ajax Queue plugin.

您可以使用Ajax Queue插件。