jQuery 发送 ajax json 请求。。

时间:2023-03-09 03:28:44
jQuery 发送 ajax json 请求。。
$.extend({
postJson: function (data) {
data = data || {} $.ajax({
type: "POST",
url: data.url,
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data.data),
success: function (resp) {
data.success(resp)
},
error: function (err) {
data.error(err)
}
})
}
})

data 参数示例 :

{
url: "/doIndex",
data: {list: [this.form]},
success: function (resp) { alert("响应信息。"); },
error: function (message) {
alert("未知的错误。。。。");
}
}

jQuery 发送 ajax json 请求。。

后台如上图所示。。 使用  @RequestBody 接受 整个 JSON 请求。。