+
80
-

请问jquery $.ajax、$.get与$.post三者的t区别及用法

请问jquery $.ajax、$.get与$.post三者的t区别及用法

网友回复

+
0
-

$post只能发送post请求

$.get("/get.php",function(data,status){
	alert("数据: " + data + "\n状态: " + status);
},"json");

$get只能发送get请求

$.post("/post.php",
   {
     name:"bfw",
     url:"http://www.bfw.wiki"
   },
   function(data,status){
    alert("数据: \n" + data + "\n状态: " + status);
   },"json");

$ajax可以发送包括get和post在内的其他method请求,还可自定义错误回调及成功回调,自定义method方法type,

$.ajax({
            url:"url",
            type:"get",
            dataType:"json",
            data:{
                userID:"1"
            },
            success:...

点击查看剩余70%

我知道答案,我要回答