2017-09-05 90 views
0

我試圖使用quotesondesign API來獲得隨機引號。我已經嘗試在文檔準備好時在http請求函數中設置$ ajax cache爲false,但沒有運氣。現在api總是返回相同的報價。它可能是cors-anywhere heroku端點嗎?任何想法如何我可以去解決這個問題?無法將緩存設置爲false使用jQuery.ajax

我的代碼:

$(document).ready(function(){ 
     $.ajaxSetup({ 
     cache: false 
     }); 
    $('#getNewQuote').on("click", getQuote); 

    function getQuote() { 
     timeStamp = new Date(); 
     $.ajax({ 
      url: 'https://cors-anywhere.herokuapp.com/https://quotesondesign.com/wp-json/posts?filter[orderby]=randfilter[posts_per_page]=1timestamp=' + timeStamp, 
      dataType: "json", 
      cache: false, 
      success: function(a) { 
       console.log(a);     
        $("#quoteContent").html(a[0].content);    
        $("#quoteAuthor").html(a[0].title); 
      } 
       });    
      } 
    }); 

回答

相關問題