Ajax Yelp API Call from Javascript -
i'm trying make call yelp api javascript, getting error. below code. believe have use oauth, don't know should put in header.
function doajax(){ var xhr = new xmlhttprequest(); var url = "http://api.yelp.com/v2/searchterm=cream+puffs&location=chicago"; xhr.onreadystatechange = function(){ if(xhr.readystate == 4 && xhr.status == 200){ var = json.parse(xhr.responsetext); } } xhr.open('get', url, true); xhr.send(); }
the problem trying access resource on different domain application. in case application resides on http://fiddle.jshell.net , resource @ http://api.yelp.com.
cors 1 way around this, see here: http://en.wikipedia.org/wiki/cross-origin_resource_sharing
Comments
Post a Comment