I’m fairly new to jquery and working with json, so please bear with me. This requires you to log into http://battlelog.battlefield.com, but once you’re there you should be able to access the following page.
I’m using code like below, but it seems to fail:
$.getJSON('http://battlelog.battlefield.com/bf3/overviewPopulateStats/280966984/bf3-us-assault/1/', function(t) {
alert('test');
});
It looks like valid json, if I go to the url in my browser and copy and paste it to a site like http://jsonviewer.stack.hu/ it doesn’t have a problem reading it.
My question is, is there anyway I can read this json data with jquery?
Thanks in advance for your time!
You cannot make Ajax requests to domains that are not the same as the one the JavaScript code is running on (see Same Origin Policy for more information).
If the target site allows JSONP requests, you can use that to get around the issue. Otherwise you will not be able to load the JSON directly via jQuery.