Skip to content

Instantly share code, notes, and snippets.

@acidtib
Created March 10, 2020 18:16
Show Gist options
  • Save acidtib/dc0e5e16c741adf251347ba37863e0c4 to your computer and use it in GitHub Desktop.
Save acidtib/dc0e5e16c741adf251347ba37863e0c4 to your computer and use it in GitHub Desktop.
function runWithJQuery(jQueryCode){
if(window.jQuery) jQueryCode();
else{
var script = document.createElement('script');
document.head.appendChild(script);
script.type = 'text/javascript';
script.src = "//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js";
script.onload = jQueryCode;
}
}
runWithJQuery(function jQueryCode(){
var cases = $(".cases")
var deaths = $(".deaths")
jQuery(function($) {
$.get("https://floridacovid.com/api/v1/cases", function (data) {
console.log(data)
cases.html(data.cases.residents + data.cases.non_residents)
deaths.html(data.deaths.residents)
})
.fail(function (error) {
console.log(error);
});
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment