多個異步ajax請求指定順序執行

一、好比2個ajax請求,把第二個ajax請求放在第一個ajax請求success方法裏面。ajax

二、ajax請求時添加 async: false,//使用同步的方式,true爲異步方式。結果是隻有等服務器返回信息之後纔會繼續執行後面的代碼。默認爲true。json

三、服務器

    ajax6 = $.ajax(
      {
     url: "/Home2/SelectyjLoginuser",
     dataType: "json",
     type: "post",
     success: function (paraResponse) {
     }
      });
        ajax7 = $.ajax(
      {
          
           url: "/Home2/Selectyjzh",
           dataType: "json",
           type: "post",
           success: function (paraResponse) {
           }
      });

//確保(ajax6, ajax7兩個請求完畢時執行
        $.when(ajax6, ajax7).done(function () {
          //所作操做
        });
    }
相關文章
相關標籤/搜索