0

When set of JQuery AJAX calls are executing synchronously I would like to show a message which AJAX call is curring executing, so that user can wait till all the calls executed.

What I tried is using the JQuery,

LoadAllData();

function LoadAllData()
{
  $('#spMsg').text('Wait, fetching data1...); 
  ajaxCallForData1();

  $('#spMsg').text('Wait, fetching data2...); 
  ajaxCallForData2();

  $('#spMsg').text('Wait, fetching data3...); 
  ajaxCallForData3();
}

But the issue is $('#spMsg') is not updating unless all the AJAX calls are executed.

I have tried the JQuery Block UI plug in, but works good for single ajax call but not for sequence of calls in a function. What is the best way to fix this?

  • Embrace the asynchronous nature of asynchronous calls. – freedomn-m Nov 25 '19 at 10:25
  • I think you should take a look a promises and how to chain them, they exactly fit your needs once you get to know how to deal with them. – Rob Nov 25 '19 at 10:26
  • 1
    Possible duplicate of [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – freedomn-m Nov 25 '19 at 10:26

0 Answers0