views:

65

answers:

1

Using the following code, I get the error in the title of this question using Chrome's JavaScript developer console:

    jQuery.getJSON("http://api.yelp.com/business_review_search?term=starbucks&location=Urbana%20IL&limit=3&ywsid=XXX",
 function(data){
  jQuery.each(data, function(i,businesses){   
   jQuery("#yelpPreview").append(businesses.url);
   if ( i == (amount - 1) ) return false;
  });
 });

In full, the error is: XMLHttpRequest cannot load http://api.yelp.com/business_review_search?term=starbucks&location=Urbana%20IL&limit=3&ywsid=XXX. Origin http://localhost:8888 is not allowed by Access-Control-Allow-Origin.

I'm using MAMP as my localhost.

Is this an issue with Yelp blocking API access to a localhost, or is there an error in my code?

A: 

I found a workaround to using jQuery's getJSON method here:

http://github.com/Yelp/yelp-api/blob/master/v1/googlemaps_example/businessSearch.html

joshholat