I have a button attached to a click handler - this makes one or more AJAX calls, depending on the number of elements in the array. I use the blockUI jquery plugin to display a message when ajax calls are made, then show the results and delete the blockUI message by calling $ .unblockUI () ;.
Problem: For some reason, no matter how many times I want the ajaxCall function to execute, after the ajax FIRST call is completed, the messaging is deleted, although the loop continues to run, and the results are displayed correctly in #result div I want the full number of iterations of the loop to complete before deleting the messaging, but it looks like it is not running sequentially. Here is the code in question:
$("#myButton").live("click", function(){ $.blockUI({ message: '<img src="new_loader.gif" /><h2>Getting Config Files</h2><small>Please be patient.</small>', css: { border: 'none', padding: '15px', backgroundColor: '#FFF', '-webkit-border-radius': '10px', '-moz-border-radius': '10px', color: '#000' } }); for (var i=0; i< myArray.length; i++) { ajaxCall(myArray[i]); } $("#results").show('slow'); $.unblockUI(); return false; });
Is there any explanation why the code AFTER the loop is executed, although the loop is not yet complete? Any help is appreciated! Thanks.
source share