southbeach
Programmer
Given the code
I am looking to answer the following questions
(a) Why do I reach 100% and responses keep appending for 10 seconds?
(b) if I move count++; within the success: or error: blocks, the script hangs and causes browser to halt; why is this?
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
Code:
$.ajax({
url: "_apiListCarriers.php",
type: "POST",
data: "a=getList",
success: function(response) {
$('#processProgressBar').css('display','block');
var objs = JSON.parse(response);
var n=getObjectCount(objs);
var count = 0;
while (objs[count]) {
var pct = (count / n) * 100;
var data = objs[count];
$.ajax({
url: "primusRateOne.php",
type: "POST",
timeout: 30000,
data: "cc="+data.rateAs+'&seq='+seq+'&cid='+data.carrierID+"&pfqual="+data.PFQUAL+"&refbgID="+data.refbgID+"&formData="+formData,
success: function(response) {
$('#progressBarRole').attr('aria-valuenow',''+Math.ceil(pct)+'');
$(".progress-bar").css("width", Math.ceil(pct) + "%").text(Math.ceil(pct) + " %");
$('#barPCT').html(''+Math.ceil(pct)+"%");
if(response === 'ERROR') {
$( "#"+data.refbgID+"" ).remove();
} else {
$("#responseTable").append(response);
}
},
error: function(response) {
$('#progressBarRole').attr('aria-valuenow',''+Math.ceil(pct)+'');
$(".progress-bar").css("width", Math.ceil(pct) + "%").text(Math.ceil(pct) + " %");
$('#barPCT').html(''+Math.ceil(pct)+"%");
}
});
window.scrollTo(x, y); y+=30;
count++; seq++;
} // while
}
});
(a) Why do I reach 100% and responses keep appending for 10 seconds?
(b) if I move count++; within the success: or error: blocks, the script hangs and causes browser to halt; why is this?
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.