Reputation: 755
I am trying to pull data using a small script I found that seems to work with any other url that produces json data, however when I use it with a url that ends in .json, i will just receive a syntax error.
//error
Uncaught SyntaxError: Unexpected token : http://frontier.ffxiv.com/worldStatus/gate_status.json?callback=jQuery21309476937903091311_1450254419566&q=select+title%2Cabstract%2Curl+from+search.news+where+query%3D%22cat%22&format=json&_=1450254419567
//code below
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
// Using YQL and JSONP
$.ajax({
url: "http://frontier.ffxiv.com/worldStatus/gate_status.json",
// The name of the callback parameter, as specified by the YQL service
jsonp: "callback",
// Tell jQuery we're expecting JSONP
dataType: "jsonp",
// Tell YQL what we want and that we want JSON
data: {
q: "select title,abstract,url from search.news where query=\"cat\"",
format: "json"
},
// Work with the response
success: function( response ) {
console.log( response ); // server response
}
});
</script>
Upvotes: 2
Views: 192
Reputation: 318162
The URL you're doing the ajax request to doesn't deliver JSONP, just regular JSON.
You get a parse error because the result is something like
{"status":0}
while jQuery expects something like
callback({"status":0})
Unfortunately it doesn't look like CORS is supported either, so the data from that URL can't be gotten from the clientside, due to the same-origin policy.
Upvotes: 5