function RequestAjax(){
// this.init(str);
};
RequestAjax.prototype.init = function(str){
var xhr = this.createXHR();
// console.log(encodeURIComponent(str));
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
var data = xhr.response;
console.log(data);
}
}
};
xhr.open("GET", "../demo.php?q="+str, true);
xhr.send(null);
};
RequestAjax.prototype.createXHR = function(){
if(typeof XMLHttpRequest != "undefind"){
return new XMLHttpRequest();
}else if(typeof ActiveXObject != "undefind"){
if(typeof arguments.callee.activeXString != "string"){
var versions = ["MSXML2.XMLHttp.6.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp"],
len = versions.length;
for(var i = 0; i < len; i ++){
try{
new ActiveXObject(versions[i]);
arguments.callee.activeXString = versions[i];
break;
}catch(e){
console.log(e);
}
}
}
return new ActiveXObject(arguments.callee.activeXString);
}else{
throw new Errow("NO XHR object");
}
};