AjaxTest.html 1 <script language="JavaScript" type="text/javascript"> /// AjaxClass 200907 /// powered by Takeshi Aoyagi /// http://www.spreadclouds.com/ - function Ajax(url, target){ this._Set(url, target); }; Ajax.prototype = { _Set:/// url:システムURL、target:HTMLタグID 10 function(url, target){ if(!this.Adapter){ while(this._Res.ADAPTERS.length >= 0){ try{ this.Adapter = eval(this._Res.ADAPTERS.shift()); break; }catch(e){} }; this.Url = url; this.Target = document.getElementById(target); 20 this.Adapter.prototype = {Owner:null}; } }, -
30
-
40
-
50
-
60
-
Send:/// type:['GET','POST']インデックス、data:送信する文字 function(type, data){ if(this.Adapter){ this.Adapter.onreadystatechange = this._CallBack; this.Adapter.Owner = this; try{ this.Adapter.open(this._Res.QUERYTYPE[type], this.Url, true); this.Adapter.send(data); this.Target.innerHTML = this._Res.READ; }catch(e){ this.Target.innerHTML = this._Res.READ_ERROR.replace('%', e); } }else{ this.Target.innerHTML = this._Res.NOREAD; } }, _CallBack:///アダプタ内のコールバック用 function(){ this.Owner.Target.innerHTML += this.Owner._Res.READING; if(this.readyState == 4){ if(this.status == 200 || (this.status == 0 && this.responseText != '')){ this.Owner.Target.innerHTML = this.responseText; }else{ this.Owner.Target.innerHTML = this.Owner._Res.HTTP_ERROR.replace('%', this.status); } } }, _Res:/// リソース { READ: '読み込み中…', NOREAD: '読み込めません', READ_ERROR: '読み込み失敗「%」', HTTP_ERROR: '読み込み失敗(Code:%)', READING: '…', ADAPTERS:/// 利用可能なアダプタ一覧 [ "new XMLHttpRequest()", "new ActiveXObject('Msxml2.XMLHTTP')", "new ActiveXObject('Microsoft.XMLHTTP')", "null"], QUERYTYPE:/// データ送信方法 [ 'GET','POST']
} 70 };
<script language="JavaScript" type="text/javascript"> var a = new Ajax('ajaxresponse.txt', 'DataView'); -
Page 1