Last active
December 19, 2015 04:09
-
-
Save calvinmetcalf/5895525 to your computer and use it in GitHub Desktop.
typical (bad) ajax worker with communist.js
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
function paralellAjax(url,callback){ | |
var quickAjax = function(url,cb){ | |
var ajax = new XMLHttpRequest(); | |
ajax.onreadystatechange = function(resp){ | |
if(ajax.readyState === 4 && ajax.status === 200) { | |
cb(JSON.stringify(ajax.response)); | |
} | |
} | |
ajax.open('GET',url,true); | |
ajax.send(); | |
} | |
cw(quickAjax,url).then(function(data){callback(null,data)},callback); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment