I am trying to grab some API data from a website (specifically Yummly), and it looks like when I try to execute a JSONP request, I get JSON data. As a result, the message "Uncaught SyntaxError: UnexpectedToken:" appears.
Code that tries to do this:
var keywords = $('#input-text').val(); var url = "http://www.yummly.com/api/recipesq="+keywords+"&_app_id=<snipped-app-id>&_app_key=<snipped-api-key>&"; $.ajax({ type: 'GET', url: url, dataType: 'jsonp', //dataType: 'jsonp json' success: function() { console.log('Success!'); }, error: function(data, data2) { console.log(data); }, //jsonp: false, //jsonpCallback: 'recipeGet' }); });
I tried converting JSON from JSONP by overloading dataType, however this did not lead to any other results than the above. I also tried changing the callback function, but when I get a syntax error, it does not go to the function. When I do not use JSONP and just use JSON, I get: "XMLHttpRequest cannot load Origin not allowed Access-Control-Allow-Origin.".
Any help would be appreciated, I'm struggling a bit with that.
source share