- バックアップ一覧
- ソース を表示
- バックアップ を表示
- Ajax/iframeを使ったAjaxでComet? は削除されています。
- 1 (2006-10-21 (土) 09:54:40)
- 追加された行はこの色です。
- 削除された行はこの色です。
PHP Classes - PHP Classes blog: Responsive AJAX applications with COMET
http://www.phpclasses.org/blog/post/58-Responsive-AJAX-applications-with-COMET.html
**インチキ訳 [#f62abdaa]
With iframes, it becomes easy to return multiple responses to a
single AJAX request. But you may ask, how does it work in practice?
iframeを使えば、1個のAJAXリクエストから複数のレスポンスを返すことができるらしい。
I have implemented a solution based on this forms generation and
validation class:
http://www.phpclasses.org/formsgeneration
Manuel Lemosさん作のiframeを使ったAJAX用PHPライブラリでこれを実現したらしい。
#blikimore
It comes with a custom input plug-in class that can submit forms using
an iframe based AJAX request. This plug-in generates an iframe and special
Javascript code to submit the current form without causing the current page
to reload.
このクラスによって生成されたFORMタグからsubmitすると、リロードせずに、動的にiframeとjavascript codeを生成し、そのiframe内でsubmitするらしい。
The server AJAX response is loaded in the iframe. The iframe has width
and height set to zero . This way, the users never see whatever is loaded
in the iframe.
サーバーのAJAXレスポンスは、iframeの中に読み込まる。iframeの幅と高さは0なので、エンドユーザーには見えない。と言うことらしい。
That class output an empty HTML page with some Javascript code blocks to
execute many possible types of actions like updating specific parts of the
page, setting Javascript variables, redirecting the browser to another page,
etc..
-ページ内の特定の部分をアップデートする
-javascriptの変数をセットする
-別のページにリダイレクトさせる
などなどのアクションを行わせるjavascriptがiframeに呼び込まれ実行されるらしい。
なるほど、そうやってXmlHttpRequestがなくてもAjaxを可能にするのね。
The AJAX class calls the PHP flush() function to make those Javascript code
blocks be sent to the browser immediately.
サーバー側でflush()を実行すると、即座にiframe内に反映されるらしい。
This way, it can update the browser page while the AJAX request action is
still running on the server side.
この方法では、AJAXリクエストのアクションがサーバーサイドで有効な状態のまま、クライアントの状態を変更できる、と言うことですな。
ナルホドォ・・・
PHP側のプロセスが死なずに生き続ければ、確かにできるかも ^^;
ずーーっと生き続ける必要がある場合でなければ使ってみる価値有りかもですね。
#blikifooter(志田)