var params= {
"phone": "123",
"sortId": "6666"
}
$.ajax({
url: 'http://192.168.0.1:8080/add',
type: 'post',
data: JSON.stringify(params),//转化为json字符串
contentType: 'application/json', // 传参格式(默认为表单) contentType: 'application/x-www-form-urlencoded'
dataType: 'json', //期望后端返回的数据类型
success: function (res) {
console.log('res', res);
}, // 成功的回调函数 res就是后端响应回来的数据
error: function(err) {
console.log('err', err);
} // 失败的回调函数
})
JQuery接口请求及传参示例
最新推荐文章于 2024-07-03 02:50:17 发布