Jquery ajax載入等待執行結束再繼續執行下面代碼操作_jquery

來源:互聯網
上載者:User

Jquery等待ajax執行完畢再繼續執行下面代碼的效果,具體代碼如下,其實就是將 jquery ajax 函數的 async 參數設定為 false 即可,該參數預設為 true:

$(document).ready(function(){   loadphpernote();   window.open('http://www.phpernote.com'); }); function loadphpernote(){   var url='http://www.phpernote.com/ajax.php';   var data='action=list';   jQuery.ajax({     type:'post',     url:url,     data:para,     async:false,//false代表只有在等待ajax執行完畢後才執行window.open('http://www.phpernote.com')語句     success:function (msg){       $('#articleList').html(msg);     }   }); } 

  下面給大家介紹jquery 載入等待效果

 var dates = this.options.form.getWidgetByName("dates").getValue();  $.ajax({    url: "http://127.0.0.1:9009/Brilliantzz/service/snproduct.do",    data:dates, beforeSend:function() {    var h = document.body.clientHeight;   $("<div class=\"datagrid-mask\"></div>").css({display:"block",width:"100%",height:h}).appendTo("body");   $("<div class=\"datagrid-mask-msg\"></div>").html("正在上傳生產資料,請稍候。。。").appendTo("body").css({display:"block",  left:($(document.body).outerWidth(true) - 190) / 2,  top:(h - 45) / 2});   }, complete:function(data) {      $('.datagrid-mask-msg').remove();   $('.datagrid-mask').remove();   },   success: function(data) {     alert("生產資料:"+data);     },   error: function(data) {        alert("上傳生產資料異常!");       }     }); 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.