Skip to content

Instantly share code, notes, and snippets.

@joshuamabina
Last active April 13, 2018 13:14
Show Gist options
  • Save joshuamabina/e1d7a7efea9e25901c0734ccafd18437 to your computer and use it in GitHub Desktop.
Save joshuamabina/e1d7a7efea9e25901c0734ccafd18437 to your computer and use it in GitHub Desktop.
<!--
Gist file for "Explaining web workers" blog issue #4.
https://github.com/joshuamabina/blog/issues/4
Joshua Mabina
mabinajoshua-at-gmail-dot-com.
WTFPLv2
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>Async</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<style type="text/css" media="screen">
body { padding: 0; margin: 0; }
#image { padding: 0; margin: 0; height: 100%; width: 100%; }
.yesno { padding: 0; margin: 0; height: 100%; width: 100%; }
</style>
</head>
<body>
<div id="image"></div>
<script charset="utf-8">
function log(str) {
console.log(str);
}
$(function() {
var wtfAPI = "https://yesno.wtf/api";
$.getJSON( wtfAPI ).done(function( data ) {
log(data.image);
$('<img>').attr('src', data.image).addClass('yesno').appendTo('#image');
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment