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("未知的错误。。。。");
                    }
                }

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

猜你喜欢

转载自www.cnblogs.com/whm-blog/p/10673733.html