function MMAjax(async){ this.async = async ? true : false; this.init = function(){ try{ this.handler = new XMLHttpRequest(); return true; }catch(e){ try{ this.handler = new ActiveXObject('Microsoft.XMLHTTP'); return true; }catch(e){ try{ this.handler = new ActiveXObject('Msxml2.XMLHTTP'); return true; }catch(e){ return false; } } } } this.not_ready = function(){ return (this.handler.readyState && (this.handler.readyState < 4)); } this.onreadystatechange = function(event){ if (!this.handler) this.init(); if (typeof event == 'function') { this.handler.onreadystatechange = event; }else{ alert('XML Sender OnReadyState event Must function'); } } this.post = function(desturl, datastream){ if (!this.handler) { this.init(); } if (!this.not_ready()) { this.handler.open('POST', desturl, this.async); if (typeof(this.handler.setRequestHeader) != 'undefined') { this.handler.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } this.handler.send(datastream); if (!this.async && this.handler.readyState == 4 && this.handler.status == 200) { return true; } } return false; } this.get = function(desturl, datastream) { if (!this.handler) { this.init(); } if (!this.not_ready()) { this.handler.open('GET', desturl + "?" + datastream, this.async); this.handler.send(null); if (!this.async && this.handler.readyState == 4 && this.handler.status == 200) { return true; } } return false; } } function oAjax(act, requesturl, param, returnformat, event, bindobj){ var param1=param; if (param1.indexOf("=")==-1) { param1="rnd="+Math.random(); } else { if (param1.indexOf("&rnd")==-1) param1=param1+"&rnd="+Math.random(); } this.act = act; this.requesturl = requesturl; this.param = param1; this.returnformat = returnformat this.callback = event; this.xml = null; this.user = function(){ this.xml = new Ajax(true); if (this.act.toLowerCase() == 'post'){ this.xml.post(this.requesturl, this.param); this.xml.onreadystatechange(this.callBackResponse); } else if(this.act.toLowerCase() == 'get'){ this.xml.get(this.requesturl, this.param); this.xml.onreadystatechange(this.callBackResponse); } } this.urlencode = function(text){ return escape(text).replace(/\+/g, "%2B"); } var me = this; this.callBackResponse = function(){ if (me.returnformat.toLowerCase() == 'xml'){ if (me.xml.handler.readyState == 4 && me.xml.handler.status == 200 && me.xml.handler.responseXML){ me.callback(me.xml.handler.responseXML, bindobj); //alert(me.xml.handler.responseXML.documentElement); } } else { if (me.xml.handler.readyState == 4){ if(me.xml.handler.status == 200 && me.xml.handler.responseText) me.callback(me.xml.handler.responseText, bindobj); else me.callback("404", bindobj); } } } this.user(); }