create xmlhttprequest
1 function createXHR() { 2 if (typeof XMLHttpRequest != "undefined") { 3 return new XMLHttpRequest(); 4 } else if (typeof ActiveXObject != "undefined") { 5 if (typeof arguments.callee.activeXString != "string") { 6 var versions = ["MSXML2.XMLHttp.6.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp"]; 7 8 for (var i = 0, len = versions.length; i < len; i++) { 9 try { 10 var xhr = new ActiveXObject(versions[i]); 11 arguments.callee.activeXString = versions[i]; 12 return xhr; 13 } catch (ex) { 14 //omit 15 } 16 } 17 } 18 return new ActiveXObject(arguments.callee.activeXString); 19 } else { 20 throw new Error("no xhr object available."); 21 } 22 }