Created
July 24, 2017 11:11
-
-
Save avian2/9393f9eae6be3cb7be44aae1e27eb4ba to your computer and use it in GitHub Desktop.
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
/* Why do this ... */ | |
load: function(url) { | |
setTimeout(function () { doload(url) }, 1); | |
} | |
doload: function (url) { | |
/* synchronous XHR */ | |
xhr.open("GET", url, false); | |
xhr.send(null); | |
/* do something with xhr.responseText ... */ | |
} | |
/* ... instead of this? */ | |
load: function(url) { | |
xhr.open("GET", url, true); | |
xhr.onreadystatechange = function() { | |
/* do something with xhr.responseText ... */ | |
} | |
xhr.send(null); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment