Last active
May 18, 2017 14:19
-
-
Save RadianSmile/9e48cd4fa58eaa04426f6de87f52c2a7 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($) { | |
$.getWeatherJSON = function ( url , callback ){ | |
$.getJSON (url , function (data){ | |
if (data && data.query && data.query.results && data.query.results.channel.item.forecast && data.query.results.channel.item.forecast[3] ){ // if data.query.results exist , do the following action. | |
callback (data) | |
}else { | |
console.info("reloading : ",url) | |
$.getWeatherJSON(url,callback) | |
} | |
}) | |
} | |
})(jQuery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使用方式
$.getWeatherJSON
替代$.getJSON
,其餘不變。