2012-12-15 25 views
0

我有這個url用於從jquery發佈數據。 如何獲取每個值$_POST['reciver']爲jquery提取多個值post

test.php?peygham=&onvan=&startdate=&enddate=&sal=5&nimsal=1&visible=1&pages=1&reciver%5B%5D=687&reciver%5B%5D=695&reciver%5B%5D=690 

的jQuery:

$('#to option').prop('selected',true); 
$.post("save.php",{ 
        peygham:$('#peygham').val(), 
        onvan:$('#onvan').val() , 
        startdate:$('#startdateM').val() , 
        enddate:$('#enddateM').val(), 
        sal:$('#sal').val() , 
        nimsal:$('#nimsal').val(), 
        visible:$('#visible').val() , 
        pages:$('#pages').val() , 
        reciver:$('#to').val() /* => MULTI VALUE */ 
        }, 
    function(data){ 

     $('#message').show(); 
     $('#message').html(data.message); 
     setTimeout(function() {$('#message').hide();}, 10000); 
     //window.location = "http://aou.ir/manage/preForm/test.php";    
    },'json'); 
}); 
+0

我不明白這一點,'$( '#爲' ).val()'將獲得匹配集合中第一個元素的值,並且由於它是一個ID,匹配集合中只應該有一個元素。你究竟如何得到多個值? – adeneo

回答

0

你可以把它作爲數組

foreach($_POST['reciver'] as $value){ 
    echo $value; 
}