So, I'm using JQuery AjaxQueue to do stuff, but the problem I have is that I can't figure out how to make it continue only after the entire queue is done. I want it to look through the table checking if stuff is deleted, then after its finished continue. What's happening now is that the stuff in the queue will be processed at the same time as the stuff around it so it doesn't do the ajax calls before continuing.
var outputString = "";
$('#errors').html("");
$("#deletingitems tbody tr").each(function() {
if(rowCounter == 1) {
htmltext.append(TopofHTMLPage());
}
var tableValA = $(this).find("td").eq(0).html();
var tableValB = $(this).find("td").eq(1).html().split("/")[0];
$.ajaxQueue({
type: "POST",
url: "@Url.Content("~/webservices/retrieve.asmx/Get")",
data: "{'index': '" + tableValA + "', 'identity': '" + tableValB + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
//http://encosia.com/2009/06/29/never-worry-about-asp-net-ajaxs-d-again/
if (msg.hasOwnProperty("d")) {
// Leave the .d behind and pass the rest of
// the JSON object forward.
outputString = msg.d;
$('#errors').append(outputString);
if(obj.valA != null) {
htmltext.append('<tr>');
htmltext.append('<td>' + obj.valA + '</td>');
htmltext.append('<td>' + obj.valB + '</td>');
htmltext.append('<td>' + obj.valC + '</td>');
htmltext.append('<td>' + obj.valD + '</td>');
htmltext.append('<td>' + obj.valE + '</td>');
htmltext.append('</tr>');
}
}
}
, error: AjaxFailed
});
if(rowCounter == 10) {
htmltext.append(BottomofHTMLPage());
rowCounter = 1;
}
else {
rowCounter++;
}
});
// Add rows until 10 rows
while(rowCounter <= 10) {
htmltext.append('<tr><td></td><td></td><td></td><td></td><td></td><td></td></tr>');
rowCounter++;
}
htmltext.append(BottomofHTMLPage());
htmltext.append('</body>');
htmltext.append('</html>');
var page = window.open('','NewHTMLPage','width=1500,height=600,scrollbars=yes');
page.document.open();
page.document.write(htmltext.toString());
page.document.close();