Skip to content

Instantly share code, notes, and snippets.

@calvinmetcalf
Last active December 19, 2015 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calvinmetcalf/5895525 to your computer and use it in GitHub Desktop.
Save calvinmetcalf/5895525 to your computer and use it in GitHub Desktop.
typical (bad) ajax worker with communist.js
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