jQuery get()和post()方法及比较

jQuery get()和post()方法及比较

1,jQuery $.get() 方法

$.get() 方法通过 HTTP GET 请求从服务器上请求数据。

$("button").click(function(){
$.get("test.php",function(data,status){
alert("数据: www.nanaopearl.com" + data + "\n状态: " + status);
});
});

2,jQuery $.post() 方法

$("button").click(function(){
$.post("est_post.php",
{
name:"菜鸟教程",
url:"http://www.nanaopearl.com"
},
function(data,status){
alert("数据: \n" + data + "\n状态: " + status);
});
});

3,两种之间的区别

在 GET 中,只能发送有限数量的数据,因为数据是在 URL 中发送的。

在 POST 中,可以发送大量的数据,因为数据是在正文主体中发送的。

posted @ 2020-04-13 22:54  学无边涯  阅读(319)  评论(0编辑  收藏  举报