Home > Web Front-end > JS Tutorial > Jquery ajax loads and waits for execution to end before continuing to execute the following code operation_jquery

Jquery ajax loads and waits for execution to end before continuing to execute the following code operation_jquery

WBOY
Release: 2016-05-16 15:30:04
Original
1549 people have browsed it

The effect of Jquery waiting for ajax to be executed before continuing to execute the following code. The specific code is as follows. In fact, it is to set the async parameter of the jquery ajax function to false. This parameter defaults to 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); 
    } 
  }); 
} 
Copy after login

Let me introduce to you the jquery loading waiting effect

 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("上传生产数据异常!"); 
      } 
    }); 
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template