Would 2 consecutive .load calls in jquery execute async?
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:
- Place the second in the callback of the first.
- Set
$.ajax({async:false})
- 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.
精彩评论