If i have a php file that outputs json data with numerical keys, like
<?php
$array[1] = "abcd";
$array[2] = "efgh";
$array[3] = "1234";
$array[4] = "5678";
echo json_encode($array);
?>
how do i access the value for say key 4? The integer in "data.4" below is breaking the code. Any help would be greatly appreciated. Thanks!
$.ajax({
type: "GET",
url: "http://localhost:8888/myapp/json/json_data",
async: false,
beforeSend: function(x) {
if(x && x.overrideMimeType) {
x.overrideMimeType("application/j-son;charset=UTF-8");
}
},
dataType: "json",
success: function(data){
//$("#box").html(JSON.stringify(data, null, 4));
$("#box").append("<br/>" + data.4)
}
});
data["4"]