Jaxel
Well-known member
I have a table with 8 rows. I execute some jQuery on this table:
This code looks at each row of the table and runs an AJAX post on that row. Each loop MUST run in order, after the previous iteration completes.
The problem I am having is it runs all 8 AJAX posts at the same time... instead of one after another. How do I fix this?
Also, how do I get the XF.ajax call to do something on failure?
Code:
init: function()
{
$target = this.$target;
var process = true,
eventID = $target.data('event'),
href = $target.data('href');
$target.find('.formRow').each(function()
{
var $row = $(this);
var $fa = $row.find('dt i');
if (process)
{
var input = {
'eventID': eventID,
'userID': $row.data('user'),
'seed': $row.data('seed'),
};
XF.ajax('POST', href, input, function(data)
{
$fa.removeClass().addClass('fa fa-check-circle-o');
},
function(data)
{
process = false;
$fa.removeClass().addClass('fa fa-exclamation-triangle');
});
}
else
{
$fa.removeClass().addClass('fa fa-exclamation-triangle');
}
});
},
This code looks at each row of the table and runs an AJAX post on that row. Each loop MUST run in order, after the previous iteration completes.
The problem I am having is it runs all 8 AJAX posts at the same time... instead of one after another. How do I fix this?
Also, how do I get the XF.ajax call to do something on failure?
Last edited: