Trying to do a while loop using $.getJSON to return progress of a certain task. The initial $.getJSON works flawlessly; however the loop never completes. I am passing certain variables through a backend php file which is the reason for the variables in the script.
$.getJSON('http://anyorigin.com/get?url=https://".$domain.".instructure.com/api/v1/courses/".$course_id."/course_copy/".$id."?access_token=".$token."&callback=?', function(data){
var progress = data.contents.progress;
alert(progress);
var elem = document.getElementById('".$id."');
elem.style.width = progress + '%';
});
var progress_check = 0;
//The part below doesn't work! //
do {
$.getJSON('http://anyorigin.com/get?url=https://".$domain.".instructure.com/api/v1/courses/".$course_id."/course_copy/".$id."?access_token=".$token."&callback=?', function(data){
var progress_check = data.contents.progress;
alert(progress_check);
var elem = document.getElementById('".$id."');
elem.style.width = progress_check + '%';
});
}
while (progress_check < 100);
I want the script to update a specific div with a new css style to display the loading bar properly. Here is the div:
<div id='".$id."-div' class='progress progress-striped active'>
<div id=".$id." class='bar' style='width: 1%'></div>
</div>
Not certain what i am doing wrong. Thanks in advance.