My quote machine works in IE, doesn't work in Chrome

Here is my code https://codepen.io/hchen/full/PQygpp/
It works in IE and iPhone.
When in chrome, no matter I click the button to get next quote, or fresh the whole page, I get the same quote. But the console log shows success. Unless I clear the cache, I can get new quote by refresh the page.

I need help on how to fix it. Thank!

  var jqxhr = $.getJSON( "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function( data ) {
    setQuote(data);
    console.log( "success" );
  })
  .done(function() {
    console.log( "second success" );
  })
  .fail(function() {
    console.log( "error" );
  })
  .always(function() {
    console.log( "complete" );
  //set color
  setBackgroundColor();
  });

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36.

https://forum.freecodecamp.org/t/random-quote-machine-api-cache-causing-quote-to-not-update-properly/176119/2?u=arielleslie

1 Like

Thank you Ariel. It works by adding $.ajaxSetup( {cache: false} ); to my code.