PhotoShare/views/js/ajax.js
Muhammad Anas Rashid 34753111ed My First Web application .. a real shitty one
My First Web application .. a real shitty one
2016-01-28 23:32:09 +05:00

18 lines
537 B
JavaScript

function ajax(method,url,mode,handler,caller){
this.requestMethod = method;
this.requestUrl = url;
this.ajaxMode = mode;
this.xmlhttp = new XMLHttpRequest();
this.xmlhttp.parent = this;
this.callBack = handler;
this.callerObject = caller;
this.send = function(){
this.xmlhttp.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
this.parent.callBack(this.responseText,this.responseXML,this.parent.callerObject);
}
}
this.xmlhttp.open(this.requestMethod,this.requestUrl,this.ajaxMode);
this.xmlhttp.send();
}
}