Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过ajax提交php数组不起作用_Php_Javascript_Jquery_Ajax - Fatal编程技术网

通过ajax提交php数组不起作用

通过ajax提交php数组不起作用,php,javascript,jquery,ajax,Php,Javascript,Jquery,Ajax,我的ajax有以下代码: function setList(str){ var postDatas = decodeURI($('#form'+str+'').serialize()); alert(postDatas); // $('#crm-feedback').html('<img src="images/ajax-loader.gif"/>'); $.ajax({ url: 'somewhere/setEmail.php',

我的ajax有以下代码:

function setList(str){
    var postDatas = decodeURI($('#form'+str+'').serialize());
    alert(postDatas);
    // $('#crm-feedback').html('<img src="images/ajax-loader.gif"/>');
    $.ajax({
        url: 'somewhere/setEmail.php',
        type: 'POST',
        //dataType : "json",
        data: postDatas,
        success: function(data){
            // $('#crm-feedback').html('Saved!').css('color','green');
            alert("test");
        }       
    });

}
?>

p、 s未设置任何会话


谢谢你

我总是使用jQuery。ajax请求如下:

$.ajax({
    url:'somewhere/setEmail.php?'+postDatas,
    success: function(result) {
        alert(result);
    }
});
差不多吧


setEmail.php中可能出现了一些问题,只是没有给您一个结果…

我从一个我正在工作的项目中得到了以下信息:

在html中:

<input type="text" name="add[id_item]" />

我认为您需要将变量视为数组。也许这会让你知道该去哪里。试试
$\u POST['email\u id'][0]
,看看你会得到什么。

会发出
警报(postDatas)工作?@Sergio是的,这就是我如何获得postDatasIs
echo
的值,与
return
的值相同?如果不是的话,你可能就不会发送任何东西回来提醒成功了。@AndrewPeacock它以前对我有用,不过这一次给了我很多问题。可能是因为我使用序列化array@Sergio它在数组中,而且我仍然无法设置会话,此$\u会话[“ThisistSSSS”]=“hello”;从不给我任何东西。我有一个不同的页面来检查会话,我对此表示怀疑,因为我已经在任何条件之前设置了会话变量
<input type="text" name="add[id_item]" />
$_POST["add"]["id_item"]