Last active
May 14, 2017 11:29
-
-
Save RadianSmile/3187ef371e30a0505b1fa9ed8fb83107 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getJsonUntilSuccess (url , callback ){ | |
$.getJSON (end_point_url , function (data){ | |
if (data.query.results){ // if data.query.results exist , do the following action. | |
callback (data) | |
}else { | |
console.info("reloading : ",url) | |
getJsonUntilSuccess(url,callback) | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
會沒有 result 是因為 Yahoo api 內部的設計不良,有興趣可以參考這篇,加個參數去看他的問題是什麼。
然後我試了一下,多 request 幾次最後還是會有資料,同學可以稍微想一下要怎麼做到。
上面程式碼提供範例參考,如果看不懂歡迎在底下留言討論。