首页 > jquery发送ajax请求,参数怎么放到http请求的body里面

jquery发送ajax请求,参数怎么放到http请求的body里面

jquery发送ajax请求,参数怎么放到http请求的body里面


使用jQuery提供的 $.post:

$.post("your service url",{
    param1 : 1,
    param2 : "tom",
},function(response){
    // 处理返回
});

$.ajax({
    url: "http://wiki.shajiquan.com/gitit-bigger"
    type: "post",
    dataType: "json",
    data: "hello world",
    headers: {'Content-Type': 'application/json'},
    success: function (res) {
        if (res.status == 1) {
            window.location.reload();
        } else {
            alert(res.message);
        }
    }
})

这里的 data 就会在 body 体中。


使用POST请求就会数据放在请求的body体中

【热门文章】
【热门文章】