ajax get & post & ajax 同步方式

ajax 同步

$.ajaxSetup({ 
    async : false 
});    

get 格式

$.get(URL,callback);

$.get("url", function(data, status) { 
    console.log(data);
}); 

post 格式

$.post(URL,data,callback);

$.post("url",{test : 12}, function(data, status) { 
    console.log(data);
}); 

ajax 格式

$.ajax({ 
          type : "post", 
          url : "register/RegisterState", 
          data : "test=" + test, 
          async : false,    // ajax同步使用false
          success : function(data){ 
            data = eval("(" + data + ")"); 
            aDataSet = data; 
          } 
          }); 

猜你喜欢

转载自blog.csdn.net/weixin_35773751/article/details/79725561