views:

23

answers:

1

Hello,

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

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.

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.

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

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

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.

Thanks for your help

A: 

You could use the Ajax Queue plugin.

Darin Dimitrov
Looks quite great. Do you have an example of how it works ?
Natim
Here's an [example](http://docs.jquery.com/AjaxQueue).
Darin Dimitrov
It seams that there is this plugin too : http://code.google.com/p/jquery-ajaxq/
Natim
Yeap, it looks nice.
Darin Dimitrov
It seems to me that Ajax Queue plugin it's more compressed and effective. It takes not more than 6 lines only for the queuing method, and it includes another method ajaxSync, which does not queue but makes that "the callbacks (success/error/complete) won't fire until all previous synced requests have been completed."
netadictos
I finally just set the `async` parameter as `false` using the `$.ajax()` method instead of the `$.post()` method
Natim
@Natim, that's a very bad idea as it freezes the browser while the request is being processed. Why use AJAX in the first place if you are going to freeze the UI?
Darin Dimitrov
To be able to show some feedback to the user, not to let him do anything else.
Natim