This is my first question here.
I have an AJAX returning JSON string, and after function.done, going through:
var arData = [];
$.each(response, function(key, value) {
var temp = [value[0], value[1]];
arData.push(temp);
//console.log(temp);
});
console.log(arData);
When I print the var temp, the result is quite normal, something like ["BUFFER STOK", 497206627]. But, when I printout the arData variable, the resulting console log is as follows:
How is that that a series of 2 dimensional arrays shows up as 4 in length, with element 0, 1, and 3?
Edit: This is the log of the response object: resulting response log
*****UPDATE*****
I'm trying to re-word my question. I'm using ajax to get json data, in pairs: [["data 1", int value 1],["data 2", int value 2],...]. From this data, I intend to create an javascript array with the same value, by using arData.push(["data 1", int value 1]);, for each pair of the json data.
This is my original code:
var arData = [];
$.ajax({
cache: false,
type: 'get',
url: 'dtsearch4.php',
data: {type : 2},
dataType: 'json',
async: false
})
.done(function(response){
$.each(response, function(key, value) {
$.each(v,function(key, value){
//var temp = [value[0], value[1]];
arData.push([value[0], value[1]]);
});
});
However, the resulting array is something like this:
v[Array[2], Array[2],[Array[2],...]
v0: Array[4]
0: "APBD-I"
1: 302462864
3: NaN
length: 4
__proto__: Array[0]
v1: Array[4]
v2: Array[4]
=> What's with array[4], and element number 0, 1 and 3? No number 2?
While what I want is an array with 2 elements:
v[Array[2], Array[2],[Array[2],...]
v0: Array[2]
0: "APBD-I"
1: 302462864
length: 2
__proto__: Array[0]
v1: Array[2]
v2: Array[2]

response?