I am trying to pass an array that looks something like this below using a $.ajax() request.
[
[
{
name: "Bob",
age: "22"
},
{
name: "Sam",
age: "28"
},
{
name: "Tom",
age: "26"
},
],
[
batch: "101",
status: "live"
]
]
As you can see there is two arrays with one that is an object.
My question is how do I pass this to codeigniter and read the information.
Currently I'm passing it to Codeigniter by doing something like this.
var submit = $.ajax({
url:$('#hiddenurl').val() + 'index.php?/home/checkout/',
type: 'POST',
data: {checkoutInformation: checkout_data_arr},
success: function(response, status, xhr) {
//do code here
}
});
and my Codeigniter controller function looks something like this.
function checkout(){
//send back Item details in JSON.
$checkoutInformation = $this -> input -> post('checkoutInformation');
print_r($checkoutInformation);
}
Currently this is the response from that function
Array
(
[0] => Array
(
[0] => Array
(
[name] => Bob
[age] => 22
)
[1] => Array
(
[name] => Sam
[age] => 28
)
[2] => Array
(
[name] => Tom
[age] => 26
)
)
)
As you can see, nothing to do with the second array that's in there. How do I parse thru the data with php to work with the data?
Can anyone point out to me what I am doing wrong?
Thank you.