Ajax不会将数据发送到我的php文件

Ajax不会将数据发送到我的php文件,php,ajax,Php,Ajax,我尝试将数据发送到php文件,但不起作用。 这是我的ajax文件 var artistIds = new Array(); $(".p16 input:checked").each(function(){ artistIds.push($(this).attr('id')); }); $.post('/json/crewonly/deleteDataAjax2', { artistIds: artistIds },function(response)

我尝试将数据发送到php文件,但不起作用。 这是我的ajax文件

 var artistIds = new Array();

    $(".p16 input:checked").each(function(){
        artistIds.push($(this).attr('id'));
    });


   $.post('/json/crewonly/deleteDataAjax2', { artistIds: artistIds },function(response){
        if(response == 'ok')
            alert('dolu');
        elseif (response == 'error')
            alert('bos');
    });
这是我的php

public function deleteDataAjax2() {

        extract($_POST);

        if (isset($artistIds))
            $this->sendJSONResponse('ok');
        else
            $this->sendJSONResponse('error');
    }

然而,我在php端的artistIds是空的。为什么?

如果不先序列化值,则无法传递数组


请参阅:

这是错误的。将
{IDs:[1,2,3]}
传递到
$。post
将发送
IDs[]=1&IDs[]=2&IDs[]=3
作为查询字符串,从而在PHP读取时使其成为一个数组。请参见=>将
var\u dump($\u post)
添加到
deleteDataAjax2
以查看您得到的确切信息。什么是
sendJSONResponse
echo?[如何通过JQuery Post传递Javascript数组,以便通过PHP$\u Post数组访问其所有内容?][1][1]: