标签:
$.get和$.post都是异步请求,如果同步就用$.ajax
$.ajax请求
$.ajax({
async:false; //使用同步Ajax请求
type: "POST",
url:"demo.php",
data: {"name":name,"age":24},
dataType:"json", //省略智能判断类型
success: function(msg){
//请求成功后的回调函数
}
error:function(msg){
//请求失败后的回调函数
}
});
$.get请求:
$.get("demo.php", {"data":data},function(msg){ //执行成功后回调函数 },"json");
$.post请求
$.post("demo.php", {"data":data},function(msg){ //执行回调函数 }, "json");
标签:
原文地址:http://www.cnblogs.com/golenet/p/4943457.html