[SOLVED] Random Quote Machine - CORS issue

Hi all,

I’m working on the random quote machine project, and I’m hitting an issue with cross-origin resource sharing (making an Ajax request to a different domain).

I’ve tried a few different things to get this working, but nothing has succeeded.

  • Using a proxy with the API URL.
  • Attempted to make the request as jsonp.
  • Attempting to change the header details in the Ajax request.

I’m getting roughly the same error every time (regardless of what I change):

I understand that the error is caused by making a request to a different domain, and I tried to get around this by using jsonp, but that didn’t seem to work.

Here’s my current code:

Can anyone nudge me in the right direction?

Update:
When I was trying to use JSONP, I was missing &_jsonp=mycallback extension to the URL. I was instead using ?callback=?.

Kind of difficult to explain. If you’ve found this answer because you’re having the same issue, feel free to comment/inbox me for more info.