Skip to content

Instantly share code, notes, and snippets.

Last active December 17, 2015 03:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Timeout with no targetable DOM feedback

Case 2

Read about this and more on the ThousandEyes blog.

<!DOCTYPE html>
<pre id="result"></pre>
<button id="myBtn">Go!</button>
<script src="//"></script>
<script src="script.js"></script>
/* global $ */
var isProcessingStarted = false,
isProcessingDone = false,
$myBtn = $('#myBtn');
$myBtn.on('click', clickHandler);
function clickHandler() {
if (!isProcessingStarted) {
} else {
function startProcessing() {
isProcessingStarted = true;
// Processing takes about two seconds before it's ready
// (could be an AJAX request)
setTimeout(processingDone, 2000);
function processingDone() {
isProcessingDone = true;
function checkIfReady() {
if (isProcessingDone) {
} else {
$('#result').append('Fail :(\n');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment