Created
March 10, 2020 18:16
-
-
Save acidtib/dc0e5e16c741adf251347ba37863e0c4 to your computer and use it in GitHub Desktop.
This file contains 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 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