Calling Json File From External Sources
Solution 1:
I get two javascript errors in your code snippet:
XMLHttpRequest cannot load http://www.tripleclickstudio.com/json/file.json?tags=location&tagmode=any&format=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
Uncaught TypeError: Cannot read property 'length' of undefined
on this line:
for(var i = 0; i < responses.length; i++) {
Because responses doesn't exist when you are running the loop. $.getJSON is asynchronous, the data isn't populated until the callback function is run (which you haven't defined). Your first problem, however, is that there is a security policy preventing you from downloading it with $.getJSON. You either need to get permission to download it for your domain (the appropriate Access-Control-Allow-Origin
in the header) or to download it via JSONP.
However, when I do that, I get a syntax error in your JSON.
Post a Comment for "Calling Json File From External Sources"