Rails ajax µÄÁª¶¯µÄÏÂÀ¿ò
# app\controllers\examples_controller.rb
ruby ´úÂë
class ExamplesController < ApplicationController
def ajax_select
@items = %w{AA BB}
end
def get_sub_items
if params[:item] == "AA"
@sub_items = %w{AA1 AA2}
else
@sub_items = %w{BB1 BB2}
end
render :partial => "select"
end
end
# app\views\examples\ajax_select.rhtml
xml ´úÂë
<%= javascript_include_tag :defaults %>
<h1>Examples#ajax_select</h1>
<p>Find me in app/views/examples/ajax_select.rhtml</p>
<%= select :obj, :att, @items, {}, :onchange => remote_function(:update => "sub_items",
:method => "get",
:with => "'item=' + value",
:url => { :controller => :examples, :action => :get_sub_items})
%>
<div id="sub_items">
<select></select>
</div>
#app\views\examples\_select.rhtml
ruby ´úÂë
<%= select(:obj, :item
Ïà¹ØÎĵµ£º
×î½üÍøÉÏÌáµÄºÜ¶àµÄÒ»¸öиÅÄî¾ÍÊÇ AJAX ÁË, ÄÇô, AJAX ÊÇÊ²Ã´ÄØ? ÒÔÏÂÄÚÈÝÒýÓÃÍøÉÏ×ÊÁÏ:
AJAXÈ«³ÆÎª“Asynchronous JavaScript and XML”£¨Òì²½JavaScriptºÍXML£©£¬ÊÇÖ¸Ò»ÖÖ´´½¨½»»¥Ê½ÍøÒ³Ó¦ÓõÄÍøÒ³¿ª·¢¼¼Êõ¡£ËüÓлúµØ°üº¬ÁËÒÔϼ¸ÖÖ¼¼Êõ£º
Ajax£¨Asynchronous JavaScript + XML£©µÄ¶¨Òå
»ùÓÚ web±ê×¼£¨sta ......
Ò».¹¤¾ßÏÂÔØ
1.ASPAJAXExtSetup.msi
http://download.microsoft.com/download/5/4/6/5462bcbd-e738-45fa-84ca-fa02b0c4e1c2/ASPAJAXExtSetup.msi
2.ASPAJAXSourceCode.msi
http://download.microsoft.com/download/6/d/6/6d6c7c47-b9ff-4934-bb03-8a45b8418d35/ASPAJAXSourceCode.msi
3.AjaxControlToolkit
http://ww ......
ŪÁËÒ»ÕûÌìÁË£¬¸Õ¿ªÊ¼Ñ§Ï°Jquery£¬ºÜ¶à¶«Î÷»¹²»Ê죬¿´¿´ÊÓÆµ£¬²é²é×ÊÁÏ£¬ÖÕÓڳɹ¦µÄ¼¯³ÉStruts2+Jquery+Json
Ö±½ÓÉÏͼ:Óû§ÃûÊäÈëxxx,½¹µã¶ªÊ§£¬Ìáʾ”Óû§ÒÑ´æÔÚ“£¬·ñÔòÌáʾ“¿ÉÒÔ×¢²á“£¬ÃÜÂëͬÑùÈç´Ë,
Ê×ÏÈÐèÒªµ¼°ü£ºÈçϳýÁËstruts2±ØÐëµÄ°üÍ⣬»¹ÓÐjson°üÒÔ¼°Éæ¼°µÄcommonsµÄ¼¸¸ö°ü.
´ËÍâҪϠ......
1¡¢ajax¼¼ÊõµÄ±³¾°
²»¿É·ñÈÏ£¬ajax¼¼ÊõµÄÁ÷ÐеÃÒæÓÚgoogleµÄ´óÁ¦Íƹ㣬ÕýÊÇÓÉÓÚgoogle earth¡¢google suggestÒÔ¼°gmailµÈ¶Ôajax¼¼ÊõµÄ¹ã·ºÓ¦Ó㬴ßÉúÁËajaxµÄÁ÷ÐС£¶øÕâÒ²ÈÃ΢Èí¸Ðµ½ÎޱȵÄÞÏÞΣ¬ÒòΪÔçÔÚ97Ä꣬΢Èí±ãÒѾ·¢Ã÷ÁËajaxÖеĹؼü¼¼Êõ£¬²¢ÇÒÔÚ99ÄêIE5ÍÆ³ö֮ʱ£¬Ëü±ã¿ªÊ¼Ö§³ÖXmlH ......
$.get()ºÍ$.post()·½·¨
$.get(url [,data] [,callback] [,type])
type£ºstringÀàÐÍ£¬·þÎñÆ÷¶Ë·µ»ØÄÚÈݵĸñʽ£¬°üÀ¨xml£¬html£¬script£¬json£¬textºÍ_default
»Øµ÷º¯ÊýÖ»ÓÐÁ½¸ö²ÎÊý£ºfunction(data,textstatus){....}
data:·µ»ØµÄÄÚÈÝ £ ......