i have a problem with JS multidimensional array and ajax, im tried many things and decide to make a join of the array to then, make a explode on php and get the array.
I decide that after look that if a send the “park” array just like that:
$.post( VIEW+THEME+"ajax/insertPark.php", {
p:Base64.encode(park),
}
I dont get the array on PHP.
Join doesnt works fine,i dont know if is because me array dont looks like: [fruit,food,meat]…
And in the console.log test the park.join make that park be the string ‘~’, with no other data.
var park = [];
$.each(languajes, function(i, itemData) {
park[i] = [];
park[i]['idLanguaje'] = itemData['idLanguaje'];
park[i]['name'] = $('#name-'+itemData['idLanguaje']).val();
});
console.log(park);
console.log(park.join('~'));
$.post( VIEW+THEME+"ajax/insertPark.php", {
p:Base64.encode(park.join('~')),
}, function(data) {
//window.location.href='/';
}, "json" );
Any idea how i can do this? The elements on the array depends of the number of languajes on database, (i.e.: the name of a park on diferents languajes), can be ES,EN or ES,EN,RU,FR… and function must adapt to this.
Thanks in advice !
Make json from your array and stringify it – Serializing to JSON in jQuery
In PHP use json_decode function