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._Adapters.length > -1){ try{ this.Adapter = eval(this._Adapters.shift()); break; }catch(e){} } this.Url = url; this.Target = document.getElementById(target); 20 } },
-
30
-
40
-
50
-
60
-
70
-
Send:/// type:['GET','POST']インデックス、data:送信する文字 function(type, data){ if(this.Adapter){ this.Adapter.onreadystatechange = this._CallBack; this.Adapter.Target = this.Target; this.Adapter.Owner = this; try{ this.Adapter.open(this._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.Target.innerHTML += this.Owner._Res.READING; if(this.readyState == 4){ if(this.status == 200 || (this.status == 0 && this.responseText != '')){ this.Target.innerHTML = this.responseText; }else{ this.Target.innerHTML = this.Owner._Res.HTTP_ERROR.replace('%', this.status); } } }, _Adapters:/// 利用可能なアダプタ一覧 [ "new XMLHttpRequest()", "new ActiveXObject('Msxml2.XMLHTTP')", "new ActiveXObject('Microsoft.XMLHTTP')", "null" ], _Res:/// リソース { READ: '読み込み中…', NOREAD: '読み込めません', READ_ERROR: '読み込み失敗「%」', HTTP_ERROR: '読み込み失敗(Code:%)', READING: '…' }, _QueryType:/// データ送信方法 [ 'GET', 'POST' ]
80 }
<script language="JavaScript" type="text/javascript"> var a = new Ajax('ajaxresponse.txt', 'DataView'); -
Page 1