I need to pass array data through ajax, and also should post back it in another page. but my code is not working, this is my code:
var data = [page_num: page, lstGend: <?php echo $gender;?>, lstFrom: <?php echo $fromyear;?>, lstTo: <?php echo $toyear;?>];
$.ajax({
type: "POST",
url: "data.php",
data:{ activitiesArray : data },
success: function(res) {
$("#result").append(res);
console.log(res);
}
});
POST the array:
$myArray = $_REQUEST['activitiesArray'];
foreach($myArray as $a){
echo $a['page_num'];
echo $a['lstGend'];
echo $a['lstFrom'];
echo $a['lstTo'];
}
Please help me guys, thnx
Send JSON data from Javascript to PHP?
Above issue is not same as mine, i need to pass multiple data(array data), please consider about this.