Created
March 26, 2014 02:32
-
-
Save fatbigbright/9775898 to your computer and use it in GitHub Desktop.
一个简单的异步执行demo
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Test page</title> | |
<script> | |
window.onload = function(){ | |
var slowTask = function(callback){ | |
setTimeout(function(){ | |
callback(); | |
}, 5000); | |
}; | |
var finishTask = function(){ | |
var resultNode = document.getElementById('result'); | |
result.innerHTML = "Got a successful result."; | |
}; | |
slowTask(finishTask); | |
}; | |
</script> | |
</head> | |
<body> | |
<div id="result">Show result after 5 seconds.</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment