Skip to main content

jQuery doesn"t .load() until .ajax() within callback of .load() is complete?



My problem is that the <div> with the jQuery progress bar ( dnc_scrubber.html ) isn't loaded until all of the other requests are complete.





Is there anyway around this? I want to change the content of #tabs-1 to the progress bar, and animate it while dnc_scrubber.php is doing its work.





The lines.php and progress.php files are used to calculate the percentage of work done by dnc_scrubber.php - which updates the session as it goes along. lines.php and files.php return the session variable.







$('#tabs-1').load('dnc_scrubber.html', function() {

var querystring = 'col=' + col + '&' + makeQS(files);

var lines = 0;



$('#progressbar').progressbar();



$.ajax({

url: 'dnc_scrubber.php',

type: 'POST',

async: true,

data: querystring,

complete: function() {

for (i = 0; i < files.length; i++) {

$('#complete').append('<a href="process/MATCHED - ' + files[i] + '">MATCHED - ' + files[i] + '</a><br />');

$('#complete').append('<a href="process/SCRUBBED - ' + files[i] + '">SCRUBBED - ' + files[i] + '</a><br />');

}

}

});



$.ajax({

url: 'lines.php',

async: true,

dataType: 'json',

complete: function(json) {

lines = json.total;

}

});





function setProgress() {

if (prog < lines) {

prog = getProgress();

$('#progressbar').progressbar('option', 'value', prog);

setTimeout(setProgress(), 1000)

} else {

$('#progressbar').progressbar('option', 'value', 100);

}

}



var prog = getProgress();

setTimeout(setProgress(), 1000);

});







I have already tried loading the progress bar within the callback function of a .ajax() request with async set to false . The same result happens - the progress bar is not loaded into #tabs-1 until dnc_scrubber.php is complete.





What can I do?


Comments

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?