function createXMLHttp() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if (window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); } throw new Error("XMLHttp object could be created."); }
function _sendRequest(url, func, isxml, postdata) { var xhr = createXMLHttp(); if (!postdata) postdata = null; xhr.open(postdata ? "POST" : "GET", url, true); if (postdata) { xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); } if (func) { xhr.onreadystatechange = function () { if (xhr.readyState == 4) { func(isxml && xhr.responseXML ? xhr.responseXML : xhr.responseText) } } } if (postdata === true) { postdata = ''; } xhr.send(postdata) }