jQuery通过 AJAX 向后端发送 JSON 数据,必须设置 contentType 值为 application/json,并且调用 JSON.stringify() 方法

// 发送ajax请求
$.ajax({
    type: "POST",
    url: 'https://shuaiguoer.com/info',
    dataType: "json",
    contentType: 'application/json',
    data: JSON.stringify({
        User: currentUser,
        password: password,
        money: money
    }),
    success(res) {
        console.log(res);
    }
});
Last modification:June 16th, 2021 at 08:42 am
如果觉得我的文章对你有用,请随意赞赏