ajax和php发送一些奇怪的值

时间:2013-10-02 11:43:24

标签: javascript php ajax

我正在尝试从复选框数组中获取一些值,我收到了这个:

Array ( [0] => [object Object] [1] => [object Object] )

我的复选框来自php循环:

$vd[]="<input type='checkbox' class='vedere' name='vedere[]' value=".$result['den_vd']."> ".$result['den_vd']." &nbsp;&nbsp;

我的javascript是:

function add_apartament ()
{
    var vedere= $('#vedere input[type=checkbox]:checked').serializeArray();
        $.ajax({
            type: "POST",
            url: "inc/ajax/add_apartament_action.php",
            data: { 
                    'vedere[]':vedere
            },
            success: function (msg) {

                $("#action").html(msg);
            },
            error: function (xhr, err) {
                alert("readyState: " + xhr.readyState + "\nstatus: " + xhr.status);
                alert("responseText: " + xhr.responseText);
            }
        });
}

现在问题是:如何从复选框中选中值?

提前致谢!

1 个答案:

答案 0 :(得分:0)

您可以尝试以下代码:

var vedere = $("#vedere input:checkbox:checked").map(function(){
   return $(this).val();
}).get();

请参阅 FIDDLE