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 请求。。

 

posted on 2019-04-08 21:50  正义的伙伴!  阅读(14835)  评论(0编辑  收藏  举报

导航

//增加一段JS脚本,为目录生成使用