Created
January 27, 2012 01:48
-
-
Save aghecht/1686417 to your computer and use it in GitHub Desktop.
Demo of Asynchronous JavaScript Events
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
<html> | |
<head> | |
<title>Test Page</title> | |
</head> | |
<body> | |
<p id="paragraph1">This is a list of key-value pairs</p> | |
<p id="paragraph2"></p> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" ></script> | |
<script language="JavaScript"> | |
console.log("Start of JavaScript") | |
$.getJSON('/data.json', | |
function(data) { | |
console.log(" AJAX Callback") | |
$.each(data, function(key, value) { | |
$('p#paragraph2').append(key + " has a value of " + value + "<br>"); | |
}) | |
}) | |
console.log("Counter..."); | |
for (var i = 0; i < 10; i++) { | |
console.log(" " + i); | |
} | |
console.log("End of JavaScript") | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment