嘗試使用ajax調用傳遞數組。傳遞json數組ajax
info = [];
info[0] = 'hi';
info[1] = 'hello';
$.ajax({
type: "POST",
data: {info: info, "action": "getPatientRecords"},
url: "/mobiledoc/jsp/ccmr/webPortal/carePlanning/servicePatientmilestoneModal.jsp",
success: function(msg) {
$('.answer').html(msg);
}
});
但是當我嘗試使用捕捉它在服務器端: 的request.getParameter(「信息」); //顯示null **
另外,如果我想發送一個數組數組?可能嗎?
我試過使用序列化,但是我的IE拋出錯誤,序列化:對象不支持這個屬性我有包括jQuery的庫。
info ['hi','hello'] ...使用這個insted你正在使用的東西,那是一個古老的wat去做數組。 –
您需要將您的json數據串聯起來。 – maketest
JSON.stringify(info); –