User:Hippietrail/hippajax.js

// abstract function to do xmlhttprequest function ajax(url, on200, on404) { var req = window.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject('Microsoft.XMLHTTP'); req.open('GET', url, true); req.onreadystatechange = function { if (req.readyState == 4) { if (req.status == 200) { // TODO handle xmlhttprequest cache bug in some msie versions if (req.responseText == '') { on404; } else { on200(req); }     } else if (req.status == 404) { on404; } else { debugPrint('bad rsc status ' + req.status + '\n'); }   }  };  req.send(null); }