0
After ajax, my php return is:
[{"1":"4"},{"2":"3"},{"3":"7"}]
Data is variable in quantity and content.
I need to treat it by javascript and convert it into an array, in this format:
var retorno = [
[1, 4],
[2, 3],
[3, 7]
];
I’m trying to:
var parsed = JSON.parse(response);
var arr = [];
for(var x in parsed){
arr.push(parsed[x]);
}
alert(arr);
response
is the variable with return data
But the result of Alert is: [object Object],[object Object],[object Object]
In this case, you are inserting an objetct into the same array... Parsed[x] will be, for example, {"1":"4"}, it is not clear to me which output you want, you want an array with the indices or an array with two members on each line of the array?
– h3nr1ke
Oops, the format I need is what’s on the var
retorno
, each json item in an array line. Vlw– sNniffer
and buddy, I didn’t understand what you reported
– sNniffer