I've written ajax oop script in javascript for registration. here is script =>
function AjaxConstruct(method,file,params){
this.method = method;
this.file = file;
this.params = params;
this.http = false;
}
AjaxConstruct.prototype.ajax = function(){
if (window.XMLHttpRequest){
this.http = new XMLHttpRequest();
} else {
this.http = new ActiveXObject("Microsoft.XMLXHTTP");
}
if (this.http){
this.http.open(this.method,this.file,true);
if (this.method==="POST"){
this.http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
}
this.http.send(this.params);
this.http.onreadystatechange = function(){
if (this.http.readyState==4 && this.http.status==200){
alert("ok");
} else {
alert("no");
}
};
}
};
and creating object like that =>
var ajax = new AjaxConstruct("POST","filename","params"); // define object
ajax.ajax(); // invoke method
everything is working perfectly but just i want to know how can i flag in oop script when result is fine and when it is not ? And also I'm interested in how many data is common to send with ajax or doesn't it matter ? For example I am trying to send data to mysql database from seven input form, Is any chance to lost data during sending with ajax script like this ? Thanks :)
I've guessed error and corrected in script above , thanks man :)