Will 2 consecutive .load calls in jquery execute async?

In a script as shown below, will load functions be called asynchronously or one after the other?

 <script language="javascript" type="text/javascript"> $(document).ready(function () { $("#TheLink").click(){ $("#PlaceToUpdate1").load("/Controller/Method/View1"); $("#PlaceToUpdat2").load("/Controller/Method/View2"); } }); }); </script> 
+4
source share
2 answers

Asynchronously, by default. If you need them to be disposable, you can do several things:

  • Put the second in the callback of the first.
  • Install $.ajax({async:false})
  • Perhaps you can even set them up in line.

The cleanest way is probably option 2.

+7
source

Yes, full call to download:

 load( url, [data], [callback] ) 

the third optional parameter is the callback method, which will be called when the asynchronous loading method is completed.

0
source

All Articles