jQuery中ajax请求有三种操作方式$.get() $.post() $.ajax()
get和post(是对$.ajax的封装)
//不传递数据
$.get("./16.php",function(msg){
alert(msg);
});
//给服务器传递数据
$.get("./16.php",{name:'tom',age:23},function(msg){
alert(msg);
});
//用法与get方法类似
$.post("./16.php",{},function(){});
$.ajax是jQuery底层的ajax方法
$.ajax({
url:"./16.php",
data:"name=tom&addr=beijing&age=23",
dataType:'text',
async:false,//同步请求,默认为异步
type:'post',
success:function(msg){
//ajax请求成功后要执行这个的代码
alert(msg);
}
});