我從這個AJAX調用中獲得undefined index(return data)
。我在這裏做錯了什麼?請糾正我。AJAX請求在PHP中提供'undefined index'錯誤
$(document).ready(function() {
$('#something').click(function() {
edit(1, 'abc', 'xyz');
});
function edit(id, column, text) {
$.ajax({
url: "edit.php",
method: "POST",
data: {
id: id,
text: text,
column: column
},
dataType: "text",
success: function(data) {
console.log(data);
}
});
}
});
edit.php
echo $_POST["id"];
我得到這個在控制檯:在Ç。ID:
注意:未定義指數\ XAMPP \ htdocs中\數據表\ edit.php on line
這錯誤意味着問題出在你的PHP代碼,而不是JS。檢查第2行的'edit.php'文件。第2行的 –
此代碼存在echo $ _POST [「id」] – EaBangalore
是「edit.php」的路徑是否正確?是:你有多個'edit.php'文件,你試圖通過任何機會發布信息? – RamRaider