javascript - Would 2 consecutive .load calls in jquery execute async? - Stack Overflow

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

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>

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>
Share Improve this question edited Oct 1, 2015 at 18:13 Francisco Noriega asked Jan 14, 2010 at 4:52 Francisco NoriegaFrancisco Noriega 14.6k11 gold badges51 silver badges72 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

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 pletes.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742306735a4419088.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信