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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM