From my understanding, we can use
async=false
to make sure that the ajax has complete.
However, I have a situation that a function will call the same ajax function multiple times while it looping thru an array of data.
Pseudocode:
function CALL_ME(){ // DATA_ARRAY contain a variable that contain a array of data. var DATA_ARRAY; var MsgStr;
for(var d=0; d<DATA_ARRAY.length; d++){ // Call.me is a AJAX function. MsgStr += Call.me(DATA_ARRAY[d]); }
}
The problem is how do I get the code to display a waiting message such as "Please wait" while waiting for the function to complete.
Please note that the the Ajax will return some data that will store into MsgStr, in which, the MsgStr data will be display in a <div> inside the same page.