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?

CCNA 1 Final Exam 2011 latest (hot hot hot)

  Hi! I have been posted content of ccna1 final exam (latest and only question.) I will post the answer and insert image on sunday. If you care, please subscribe your email an become a first person have full test content. Subcribe now  Some question  have not content because this question have images content. So that can you wait for me? SUNDAY 1. A user sees the command prompt: Router(config-if)# . What task can be performed at this mode? Reload the device. Perform basic tests. Configure individual interfaces. Configure individual terminal lines. 2. Refer to the exhibit. Host A attempts to establish a TCP/IP session with host C. During this attempt, a frame was captured with the source MAC address 0050.7320.D632 and the destination MAC address 0030.8517.44C4. The packet inside the captured frame has an IP source address 192.168.7.5, and the destination IP address is 192.168.219.24. At which point in the network was this packet captured? leaving host A leaving ATL leaving...