Ajax

Ajax.Requestもどき隠しフレーム通信

2007/12/19追記。onExceptionオプションを追加しました。例外発生時の処理も変更しています。 2007/12/03追記。Opera9.24に対応しました。以前書いたように、IE7ではローカル環境でAjaxが使えません。今まで使えたのに・・・。拙作theater.jsはprototype.js…

最近知ったこと

たぶんほんとに今さらですが。 IE7のXMLHttpRequestでローカルファイルが参照できない。 responseXMLはIE6でもそうだったけど、responseTextまでとは・・・。theater.jsのreadmeがIE7で表示できなかったので、変だなと思ったらそういうことか><;たしかに…

Ajax.Requestでのフォームデータ送信サンプル(postBodyへの設定)

Ajax.Requestでのフォームデータ送信サンプルを載せておきます。ポイントはForm.serializeメソッドです。これがフォーム内容をpostBodyプロパティに適合した文字列に変換してくれます。 [test.htm]UTF-8で記述 <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <script language="javascript" src="./prototype.js" charset="utf-8"></script> <…</meta></head></html>

Ajax.Requestでのフォームデータ送信サンプル(postbodyへの設定)

※http://d.hatena.ne.jp/susie-t/20070531/1180585173 へ移しました。

Ajax.PeriodicalUpdaterクラス

【抜粋】一部省略 Ajax.PeriodicalUpdater = Class.create(); Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), { initialize: function(container, url, options) { (省略) }, (省略) onTimerEvent: function() { this.updater = new Aj…

Ajax.Updaterクラス

【抜粋】一部省略 Ajax.Updater = Class.create(); Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), { initialize: function(container, url, options) { (省略) }, (省略) if (this.responseIsSuccess()) { if (this.onComp…

Ajax.Requestクラス(2)

respondToReadyStateメソッド 【抜粋】 respondToReadyState: function(readyState) { var event = Ajax.Request.Events[readyState]; var transport = this.transport, json = this.evalJSON(); if (event == 'Complete') { try { (this.options['on' + thi…

Ajax.Requestクラス(1)

【抜粋】一部省略 Ajax.Request = Class.create(); Ajax.Request.Events = ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; Ajax.Request.prototype = Object.extend(new Ajax.Base(), { initialize: function(url, options) { this.tr…

Ajax.Baseクラス

【抜粋】一部省略 Ajax.Base = function() {}; Ajax.Base.prototype = { setOptions: function(options) { this.options = { method: 'post', asynchronous: true, parameters: '' } Object.extend(this.options, options || {}); }, (省略) responseIsFailu…

XMLHttpRequestのresponseTextで扱える文字コードについて

よく分かっていない部分もありますが、備忘録としてメモします。XMLHttpRequestオブジェクトのresponseTextプロパティは、(ほとんどのブラウザで)デフォルトでは文字コードUTF-8とみなされます。が、ブラウザよって違いはありますが、他の文字コード(shift_j…

Ajax.Respondersオブジェクト

【抜粋】一部省略 Ajax.Responders = { responders: [], (省略) dispatch: function(callback, request, transport, json) { this.each(function(responder) { if (responder[callback] && typeof responder[callback] == 'function') { try { responder[cal…

Ajaxオブジェクト

prototype.js解読のもう一つの山場。というか、ここが肝でしょうか。Ajax.Responders, Ajax.Base, Ajax.Request, Ajax.Updater, Ajax.PeriodicalUpdaterはそれぞれ別に解読します。Ajaxオブジェクトは上記のAjax関連のクラス・オブジェクトの名前空間(他と名…