Here's my code based off this question
$(document).ready(function(){
$('#new-quote').click(function(){
var url = 'http://api.forismatic.com/api/1.0/?format=jsonp&jsonp=_';
$.getJSON(url, function(data){
console.log(data);
});
});
});
This get's me the error:
XMLHttpRequest cannot load http://api.forismatic.com/api/1.0/?format=jsonp&jsonp=. Redirect from 'http://api.forismatic.com/api/1.0/?format=jsonp&jsonp=' to 'http://forismatic.com/' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
I've also tried the code:
$(document).ready(function(){
$('#new-quote').click(function(){
var url = 'http://api.forismatic.com/api/1.0/?format=jsonp&jsonp=_';
$.getJSON(url).done(update).fail(err);
function update(response){
console.log(response);
}
function err(jqxhr, textStatus, err){
console.log('Request failed');
}
});
});
And it gives me the same error. Along with the 'Request failed message'. I'm using jQuery 3.1.1. What am I missing here? Sorry if this is a duplicate but I've read the questions here and haven't found the answer
This question asks about the underlying concept of Access-Control-Allow-Origin. The guy also literally states that he doesn't want to use jsonp. I want use jsonp format with $.getJSON format and am not sure why it's not working.