prog_cgi:ajaxによる更新
差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン | 最新のリビジョン両方とも次のリビジョン | ||
prog_cgi:ajaxによる更新 [2019/03/11 10:22] – [デフォルトアクションの実装] hirohito | prog_cgi:ajaxによる更新 [2019/03/11 10:25] – hirohito | ||
---|---|---|---|
行 122: | 行 122: | ||
現在のブラウザでは、この指示をしてもしなくても正しく動作するものがほとんどですが、念の為つけています。 | 現在のブラウザでは、この指示をしてもしなくても正しく動作するものがほとんどですが、念の為つけています。 | ||
+ | これで完了です。 | ||
+ | {{: | ||
+ | |||
+ | |||
+ | ===== プログラム全体 ===== | ||
+ | | ||
+ | |||
+ | * コントローラ main.rb | ||
+ | * テンプレート(ビュー) index.rhtml | ||
+ | |||
+ | |||
+ | <code ruby main.rb> | ||
+ | require " | ||
+ | require " | ||
+ | |||
+ | class AjaxSampleController < AlController | ||
+ | def action_index() | ||
+ | AlTemplate.run(" | ||
+ | end | ||
+ | |||
+ | def action_get_graph() | ||
+ | form = AlForm.new( | ||
+ | AlText.new(" | ||
+ | AlText.new(" | ||
+ | AlText.new(" | ||
+ | AlText.new(" | ||
+ | ) | ||
+ | form.validate() | ||
+ | ydata = [ form[: | ||
+ | |||
+ | graph = AlGraph.new() | ||
+ | graph.set_mode( : | ||
+ | |||
+ | graph.add_data_bar(ydata) | ||
+ | graph.draw() | ||
+ | end | ||
+ | end | ||
+ | </ | ||
+ | |||
+ | <code html index.rhtml> | ||
+ | <%= header_section %> | ||
+ | < | ||
+ | input[type=text] { text-align: right; } | ||
+ | </ | ||
+ | |||
+ | <%= body_section %> | ||
+ | |||
+ | <div id=" | ||
+ | |||
+ | 値1< | ||
+ | 値2< | ||
+ | 値3< | ||
+ | 値4< | ||
+ | |||
+ | <script src=" | ||
+ | <script src="/ | ||
+ | < | ||
+ | $(" | ||
+ | var v1 = $(" | ||
+ | var v2 = $(" | ||
+ | var v3 = $(" | ||
+ | var v4 = $(" | ||
+ | |||
+ | var uri = Alone.make_uri({action:" | ||
+ | $("# | ||
+ | }); | ||
+ | </ | ||
+ | |||
+ | <%= footer_section %> | ||
+ | </ | ||
prog_cgi/ajaxによる更新.txt · 最終更新: 2019/03/18 22:40 by hirohito