/*
var ajx=new HHLAjax("dll/testDT.jsp");
ajx.callback=function(){
//do something ...
//document.write(ajx.getText());
};
ajx.submit();
*/
function HHLAjax(url,async){
var self=this;
self.URL=url;
self.XHR=null;
self.ASYNC=async || false;
self.getText=function(){
return self.XHR.responseText;
};
self.getXml=function(){
return self.XHR.responseXML;
};
self.create=function(){
try{
self.XHR = new ActiveXObject("Msxml2.XMLHTTP");
}catch (e1){
try{
self.XHR = new ActiveXObject("Microsoft.XMLHTTP");
}catch (e2){
self.XHR = null;
}
}
if (! self.XHR){
if (typeof XMLHttpRequest != "undefined"){
self.XHR = new XMLHttpRequest();
}
else{
alert("Create XMLHttpRequest failed!");
}
}
};
self.callback=function(){
alert(self.getText());
};
self.onerror = function(){
alert(" Ajax Error :/n"+"status : "+self.XHR.status+"/nError : "+self.XHR.statusText);
};
self.submit = function() {
self.XHR.open("POST", self.URL, self.ASYNC);
try {
self.XHR.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
} catch (e) { }
self.XHR.onreadystatechange = function() {
if(self.XHR.readyState==4) {
if(self.XHR.status != 200){
self.onerror();
}
else{
self.callback();
}
}
};
self.XHR.send();
};
self.create();
}