Reputation: 984
I'm requesting a json feed using the standard jquery getJson request. The json url is not hosted on my domain.
$.getJSON('myfeed.json?jsoncallback=?',
function(data){
console.log(data);
})
However using Firebug, I'm not seeing any data logged in the console. But I can see the json data has been loaded as is available when I look under the Net panel in Firebug.
Anyone know why this is?
Sample JSON
[{
"person": {
"name": "Bob",
}
},
{
"person": {
"name": "Dave",
}
},
{
"person": {
"name": "Jim",
}
}
}]
Upvotes: 0
Views: 948
Reputation: 104196
Make sure that the json data is well formed and also that the server returns an appropriate content type. Place a breakpoint at the console.log. Most probably this isn't executed as the callback doesn't run for some reason.
Upvotes: 0
Reputation: 6484
I think the getJSON method doesn't parse the content unless you're content-type header is text/json. You can either change your server side header or perhaps do something like this
$.get("http://MYURL", function(data){
var jsondata = eval("("+data+")")
}
Upvotes: 0
Reputation: 85862
Make sure that:
javascript:console.log('test')
into the address bar to see if anything comes up - sometimes you need to refresh the page in order to get the console running properly.Upvotes: 1