我有兩個不同的數組,即main_name []和sub_name []。 我必須使用AJAX將這些值傳遞到下一頁,以便插入到DB中。請您幫我解決,我怎樣才能將數組作爲AJAX中的數據傳遞。 HTML將文本框數組傳遞給ajax json
<input type="text" name = "main_name[]" value = "" >
<input type="text" name = "sub_name[]" value = "" >
JS
$.ajax({
type: "POST",
dataType: "json",
url: "response.php", //Relative or absolute path to response.php file
data: data,
success: function(data) {
$(".the-return").html
);
alert("Form submitted successfully.\nReturned json: " + data["json"]);
}
});
return false;
});
});
嘗試'數據:$( '形式')序列化()''中ajax' – Tushar
@Tushar你能建議我在代碼格式請 – user1894647