submit a php array via ajax does not work


I have this code for my ajax:

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


postDatas value is "email_id[]=1&email_id[]=2&test=asd"

In my form I have a multiple select that has an array for its name, name="email_id[]".

Now my problem is that I cant seem to get my ajax request to succeed, and I cant identify the lying cause of this problem.

I setup some sessions in setEmail.php so that I can check if the ajax request was submitted.

$_SESSION["thisistessss"] = "hello";

    $sql_clr = " DELETE FROM table WHERE grp_id = '".$_POST['gid']."' ";
    $res_clr = mysql_query($sql_clr);
    $_SESSION["testagain5"] = $_POST['email_id'];
    foreach($_POST['email_id'] as $key => $val) {
        $_SESSION["testagain31"] = "testsss".$val;

        $_SESSION["testagain3"] = "testsss".$_POST['dval'];

        if($val!='' && $_POST'dval']!='') {
        $_SESSION["testagain4"] = "testsssss".$_POST'dval'];
            //insert into database
                $val = str_replace("-sms","",$val);
                $sms_on = 1;
                $sms_on = 0;
            $sql_ins = " INSERT INTO table (grp_id, email_id, email_sched, sms) VALUES ('".$_POST['gid']."','".$val."','".$_POST'dval']."', '".$sms_on."') ";
            $res_ins = mysql_query($sql_ins);
            $_SESSION["testagain2"] = $sql_ins;
                echo "1";
    echo "1";

    echo "1";


p.s none of the sessions are being set

Thank you

I got this from a project I am working in:

In the html:

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

In the php:


I think you need to treat the variable as an array. Maybe this gives you some idea where to go. Try $_POST['email_id'][0] and see what you get.