我嘗試用ajax發送我的數據到php,但有一個奇怪的錯誤。用ajax發送數據到php - 內部服務器錯誤(500)
這是我的AJAX腳本,
function deleteData2()
{
var artistIds = new Array();
$(".p16 input:checked").each(function(){
artistIds.push($(this).attr('id'));
});
$.post('/json/crewonly/deleteDataAjax2',
{ json: JSON.stringify({'artistIds': artistIds}) },
function(response){
alert(response);
});
}
我覺得這工作正常,但在PHP的一面,我面對500內部服務器錯誤(500)。
public function deleteDataAjax2() {
$json = $_POST['json'];
$data = json_decode($json);
$artistIds = $data['artistIds'];
$this->sendJSONResponse($artistIds);
}
上面的代碼是我的PHP。例如,當我嘗試$數據發送到阿賈克斯, 打印我的ID在JSON模式:
然而,當我嘗試發送$ artistIds到阿賈克斯,我給了500錯誤,爲什麼?
檢查您的Web服務器錯誤日誌,它會給你,爲什麼你得到500的更多信息錯誤。 – 2012-03-25 10:19:04
注意:未定義的索引:json why:S – user1277467 2012-03-25 10:33:20
嘗試'$ _REQUEST ['json']' – Dutchie432 2012-03-25 10:40:06