开发者

Would 2 consecutive .load calls in jquery execute async?

开发者 https://www.devze.com 2022-12-17 10:07 出处:网络
In a script like the following, would the load functions be called in asynchronously or one after another?

In a script like the following, would the load functions be called in asynchronously or one after another?

<script language="javascript" type="text/javascript">

    $(document).ready(function () {

          $("#TheLink").click(){        
                $("#PlaceToUpdate1").load("/Controller/Method/View1开发者_开发百科");
                $("#PlaceToUpdat2").load("/Controller/Method/View2");

          }

        });
    }); 
</script>


Asynchronously, by default. If you need them to be one-after-the-other, you can do a few things:

  1. Place the second in the callback of the first.
  2. Set $.ajax({async:false})
  3. You could possibly even set these up in a queue.

The cleanest way is probably option 2.


Yes, the full call for load is:

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

the third optional parameter is a callback method that will be called when the asynchronous load method completes.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号