Hello,
I have an issue with javascript/jQuery...I have a web service that will process information from a list from the client. What I want to do is have the client send the data piece by piece allowing the web service to do its job without being overloaded. Also I am using a jQuery UI progressbar which will allow the user to see the progress of their request.
My problem is that I am using a for loop and when the loop runs it seems that the loop runs to completion so if there are 10 pieces of data to process, all ten runs simultaneously...
What I'm asking is there a way to make the for loop pause until a success message is received from the server?
This is what I tried:
var nums = [1,2,3,4,5,6,7,8,9,10];
for (var i in nums) {
//I also tried
//for (num = 1; num <= 9; num++) {
//start loop
$("#progressbar").progressbar('option', 'value', num);
var input = {
"num": num,
"total": 100
}
// .progressbar('option', 'value', 37);
var jsonStr = JSON.stringify(input);
//d = '{' + d + '}';
$.ajax({
type: "POST",
url: "AjaxWcf.svc/TestModal",
contentType: "application/json; charset=utf-8",
data: jsonStr,
dataType: "json",
success: function(msg) {
$("#progressbar").progressbar({
value: num
});
//alert(msg.d);
// jQuery('#modalContentTest.loading').fadeOut(200);
// setTimeout('jQuery.modal.close()', 1000);
$("#message").value = msg;
},
error: AjaxFailed
});
}
function AjaxFailed(result) {
alert(result.status + ' ' + result.statusText);
}
});
I know its late so maybe I'm crosseyed and maybe some sleep will help me see this from a different angle, buuuuuttt if someone could help with this or show me an alternetive, I'd appreciate it.
Thanks!!!