Page 1 of 1

Ayuda con array

PostPosted: Thu Dec 07, 2017 4:58 am
by djmarkes
Buenas. vuelvo a tener problemas para trabajar con un array.

Llamo a un script en mi servidor que me genera los resultados en un array.

Tengo este codigo para la llamada:

Code: Select all
BeginJS
var url="http://xxxx.com/script.php";
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
    if (request.readyState === 4) {
        if (request.status === 200) {
            document.body.className = 'ok';
            $rootScope.res = request.responseText;
        } else {
            document.body.className = 'error';
        }
    }
};
request.open("GET", url , false);
request.send(null);
EndJS


Todo correcto, se almacena el resultado en la variable [res] de esta forma, este es el contenido:

[["12","46541.66"],["405","11729.68"],["176","16588.84"],["945","110162.39"],["477","21640.98"],["583","28344.36"],["1096","85405.80"],["749","24210.74"],["582","40753.60"],["1342","47796.64"],["2193","24647.16"],["492","47661.21"],["996","16505.49"],["2074","50377.71"],["900","167387.68"],["513","93502.17"],["1349","26585.16"],["136","48308.66"],["1021","22238.08"],["1031","19497.86"],["1265","23086.81"],["275","11875.26"],["35","17678.97"],["317","30919.68"],["194","25981.78"],["885","40977.53"],["20","22154.17"],["1945","29541.48"],["319","36430.83"],["540","38644.07"],["746","17850.38"],["1117","45460.98"],["998","16983.13"],["1429","69794.37"],["691","19534.23"],["1671096","11418.30"],["981","39643.50"],["167513","10346.96"],["1463","5077.05"],["327","33550.56"]]

Necesito acceder a esos datos y no se como, por ejemplo el primer elemento de ese array serĂ­a:

elemento: 12 valor: 46541.66
el siguiente:
elemento: 405 valor: 11729.68

Puede alguien guiarme un poco?

Gracias!