Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #253427
    jboo
    Participant

    When running a jQuery ajax request for a random quote using the noted API in Chrome through CodePen, the response always returns the same quote. The pen works fine when using IE11 and Edge, and entering the API call in the Chrome address bar returns a randomized quote as expected.

    Anyone have any tips on what’s causing this behavior with CodePen on Chrome?

    Pen: https://codepen.io/jfleshman/pen/gLdKeo
    API Call: https://quotesondesign.com/wp-json/posts?filter%5Borderby%5D=rand&filter%5Bposts_per_page%5D=1
    API Doc: https://quotesondesign.com/api-v4-0/

    #253428
    Shikkediel
    Participant

    Try adding cache: false to the Ajax call…

    #253431
    jboo
    Participant

    That was the ticket! Thank you greatly for the help.

    Would you be able to explain why setting cache to false was necessary only for Chrome? The prior API I used did not have this issue(I had been using $.getJSON for simplicity, so I assume it employs mostly default arguments)

    #253433
    Shikkediel
    Participant

    I can’t really explain, just noticed it did the trick for both Firefox and Chrome.

    #253434
    jboo
    Participant

    I’ll add that to my list of web development mysteries, and I’ll have to remember this solution in the future! Again, many thanks. The issue was a big head scratcher for me.

    #253442
    Shikkediel
    Participant

    No problem, it’s strange indeed because false should already be the default for caching jsonp.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.