Hi,
I'm having a problem when using the jquery .each() and .ajax() functions together. I'm using .each() to loop through 5 elements and am performing the .ajax() call for each one. My problem is that I only want the loop to continue when a response has been received from each ajax request. Currently, all 5 elements are being looped, 5 ajax requests being made, then 5 responses being returned.
Hers's a simple example:
$(".element").each(function() {
var id= $(this).find(('txtId').val();
$.ajax({
type: "POST",
url: "/Handlers/Handler.ashx",
data: "ID=" + id,
success: function(xml){
// I would like the each() loop to pause until this is hit,
// and some additional logic can be performed.
}
});
});
Cheers.