My code looks like this:
$.get('http://files.mysite.com/data.json', function(data) {
console.log(data);
}, "jsonp");
When I take a look inside the Network
menu from Firebug I can see a valid call to my JSON
file and when I open it, it conains all the information.
But the Console
remains silent. No sign of an AJAX
call nor my logging of data
.
My AJAX
call is not on the same domain as my JSON
file. Thats why I'm using jsonp
Any ideas??
I'm not entirely sure what your problem is, if you get a result but the console stays quiet you could have issues with the JSON itself... try JSONLint to find issues.
Also I would recommend you don't use getJson etc.
$.ajax({
url: http://files.mysite.com/data.json,
dataType: 'jsonp',
cache: false,
beforeSend: function () {
console.log("Loading");
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
},
success: function (data) {
console.log('Success');
console.log(data);
},
complete: function () {
console.log('Finished all tasks');
}
});
This way you get some error handling and other nice little features, you could add a loading spinner via beforeSend, and remove it via complete :)
Edit: Replace the error function with the one below, that should give us a better idea of what the problem is :)
error: function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With