I have the following code to pass a Javascript array to PHP using ajax :
in HTML :
echo "<input type=\"hidden\" id= \"que_id\" name= \"que_id[]\" value=".$questions['que_id'].">";
This is inside a loop.
in Javascript :
var que_id_array = new Array();
$('input[name="que_id[]"]').each(function(){
que_id_array.push($(this).val());
});
AJAX Call :
$.ajax({
type:"POST",
url: 'questionmastermodify.php',
data: { que_id:que_id_array},
success: function(data) {
$('.my_update_panel').html(data);
$('#overlay').fadeOut();
}
});
in PHP :
$que_id = $_REQUEST['que_id'];
echo count($que_id);
The count displays 1 and not the size of the array, whereas in Javascript the console shows :
console.log(que_id_array);
output :
["151", "152", "153", "154", "155", "156", "157", "158", "159", "160", "161", "162", "163", "164", "165", "166", "167", "168", "169", "170", "171", "172", "173", "174", "175", "176", "177", "178", "179", "180", "181", "182", "183", "184", "185", "186", "187", "188", "189", "190", "191", "192", "193", "194", "195", "196", "197", "198", "199", "200"]
I am stuck as i need this array in PHP but unable to pass this array from JS to PHP.
Thanks in advance....
Sandy505