Getting JSON to work - Build a Random Quote Machine

Can someone explain why my code isn’t working? My ultimate goal with this code is to get a JSON object from I’m making use of JSONP but it doesn’t work. Can someone review my code and educate? I’d also take any resources on learning to use ajax.

The success and always case just have html functions so I can see if they run.


$('h2').on('click', function(e) {
    url: "[orderby]=rand&filter[posts_per_page]=1&_jsonp=mycallback",
    jsonp: "callback",
    dataType: "jsonp",
    success: function( response ) {
      console.log( response ); // server response
    always: function(response) {

Try getting rid of your jsonp option, and get rid of the _jsonp=mycallback in your URL.

That won’t work. That causes cross origin problems apparently.

It seems that despite what the documentation says on, we’re not actually going to be using JSONP. Do as suggested before, but also add a CORS proxy to make the request work. is an easy choice. Prepend it to the URL like so:[orderby]=rand&filter[posts_per_page]=1

Wow. This looks promising. Thanks for the help.

Ah, I didn’t realize that quotesondesign now uses HTTPS. Good call, that’s better than using a proxy for sure.

Huh. It words now. It seems that changing to http to https fixed it. Thanks all!