JQuery.AJAX not working though firefox says code 200

I cannot get jQuery to return to success, even if the URL that it creates is working. The code is as follows:

var baseURL = "http://api.rottentomatoes.com/api/public/v1.0.json"; var apiKey = "myAPIKEy"; $.ajax ({ type: "GET", url: baseURL, data: { apikey: apiKey }, success:function() { alert('here'); }, complete:function(data) { return data; } }); 

This is not a successful success (I took out the failure, but he went into failure). I'm not sure why this fails if I copy the generated generated url and it works and returns a response. Please let me know what other information I can provide. I'm sorry that I'm a little vague. Any help is much appreciated !!!

+6
source share
3 answers

This will work for cross domain

 var baseURL = "http://api.rottentomatoes.com/api/public/v1.0.json"; var apiKey = "myAPIKEy"; $.getJSON (baseURL + "?callback=?", { apikey: apiKey }, function(data){ return data; }); 
+4
source

Per Rotten Tomatoes you can use JSONP:

 http://api.rottentomatoes.com/api/public/v1.0.json?apikey=[your_api_key]&callback=mycallbackfn 

A simple example:

$. getJSON (http://api.rottentomatoes.com/api/public/v1.0.json, {apikey: apiKey, callback: uniqueCallback});

UniqueCallback function (data) {// Data will be sent to this function}

0
source

Found a solution. You must change it to JSONP for rotten tomatoes. Lesson learned, consult documentation in future ...

http://developer.rottentomatoes.com/docs/read/json/v10/examples

0
source

All Articles