登録用にjavascriptでajaxoopスクリプトを作成しました。これがスクリプトです=>
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");
}
};
}
};
そしてそのようなオブジェクトを作成する=>
var ajax = new AjaxConstruct("POST","filename","params"); // define object
ajax.ajax(); // invoke method
すべてが完全に機能していますが、結果が正常な場合とそうでない場合に、oopスクリプトでフラグを立てる方法を知りたいだけです。また、ajaxで送信するのに一般的なデータの数に興味がありますか、それとも重要ではありませんか?たとえば、7つの入力フォームからmysqlデータベースにデータを送信しようとしていますが、このようなajaxスクリプトを使用して送信中にデータが失われる可能性はありますか?ありがとう :)
私はエラーを推測し、上記のスクリプトで修正しました、ありがとうございます:)