我的參數(shù)中有數(shù)組:比如var req = {
ids: [1, 2, 3]}ajax 寫法必須把 req 進行字符串化,然后設(shè)置 contentType: "application/json"后臺才可以正常的接受到傳來過來的數(shù)組$.ajax({ url: '/.../delete-by-ids', type: 'post', data: JSON.stringify(req), dataType: 'json', contentType: "application/json", traditional:true, success: function (data) { callback(data); }, error: function (data) { $.dialog("錯誤"); }})我已經(jīng)設(shè)置了 JSON.stringfy(req),那么 req 按理來說現(xiàn)在應(yīng)該已經(jīng)是 string 類型了,為什么 contentType 卻還是要設(shè)置為 application/json
ajax 傳遞數(shù)組參數(shù)
qq_遁去的一_1
2018-11-07 13:14:48