First, the code in question:
ajax = function(url, cb)
{
xhr = (window.XMLHttpRequest)
? new XMLHttpRequest()
: new ActiveXObject('Microsoft.XMLHTTP');
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4 && xhr.status == 200)
{
cb(xhr.responseText);
};
}
xhr.open('get', url, true);
xhr.send();
};
Now, I know I could easily opt for a library solution, but at the moment I'm trying to roll together a far more lightweight library for personal use; is this function missing anything crucial?