I wonder if I can access an array through jQuery by its index like this: output_string['color'][1]
I actually, build an array of elements like this (it works):
PHP
$arreglo = array(
'color' => $skin['Color'],
'textu' => $skin['ImagenTextura'],
'header' => $skin['Imagen'],
'sombra' => $skin['ImagenSombra'],
'tooltip' => $skin['TooltipColor']
);
echo json_encode($arreglo);
And if I want to get to the file, I get the array like this:
$.ajax({
url: 'ajax.php',
type:'POST',
dataType : 'json',
data: { 'dataString': result },
beforeSend: function(){
$("#loader").show();
},
success: function(output_string){
alert(output_string['color']);
}
});
The problem is that, this time, more than one loop will be loaded, so I need to access it like this: output_string['color'][1]
Thanks
$skin['Color']is a non-associative array it will be encoded as a JSON array, and you'll be able to reference its items numerically. Are you getting any errors when you try to do it?