Shortest way to create an XHR in Javascript

April 18, 2007 – 5:47 pm

Nicolas Faugout has a very neat, and tiny, method for creating an XHR object in different browsers:

if (!XMLHttpRequest) {
window.XMLHttpRequest = function() {
return new ActiveXObject('Microsoft.XMLHTTP');
}
}

// ....

var xhr = new XMLHttpRequest();

Via Ajaxian

Post a Comment