Fist off, here's the jSON object I created with PHPs json_encode function
{
"Gatwick":[
{
"destination":"VCE",
"destination_name":"Venezia Marco Polo"
},{
"destination":"VCE",
"destination_name":"Venezia Marco Polo"
},{
"destination":"VCE",
"destination_name":"Venezia Marco Polo"
}
],
"Heathrow":[
{
"destination":"VCE",
"destination_name":"Venezia Marco Polo"
},{
"destination":"VCE",
"destination_name":"Venezia Marco Polo"
}
]
}
Which I think is ok as I understand it. I requested the object using jQuerys $.getJSON(...) function.
Assuming all of that is correct, I can't for the life of me figure out how to access the data in the json object or even illicit any kind of response to indicate anything is happening under the hood.
My latest attempt was to copy the example from the jQuery docs like this...
$.getJSON(url, callBack);
function callBack(data){
$.each(data.items, function(i, item){
alert("YO");
});
}
Which generates the following javascript error
jquery-1.2.6.min.js (line 19) TypeError: Result of expression 'object' [undefined] is not an object.
Which is a little cryptic. Especially since using this
function callBack(data){ alert(data); }
says [object Object]
but this
function callBack(data){ alert(data[0]); }
gives me nothing.
Where am I going wrong here?