synchronize calls to the server from each() loop

synchronize calls to the server from each() loop

Hi,

I'm sending some html selected paragraphs from an iframe to the server to update a database.

I have something like:


$(".selected", $(frame).contents()).each(function(){
 ...
sendToDB($(this));

}

But sometimes it takes time to update the database and not all the paragraphs are sent to the data base.

is there a way to synchronize this loop with the response from the server?