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
Ïà¹ØÎĵµ£º
´´½¨ÓÃÓÚ±£´æÍ¼Æ¬µÄ±í£º
create table stockImages
( imageid int primary key identity(1,1),
[filename] varchar(50),
img varbinary(max))
²åÈë±¾µØÍ¼Æ¬£º
insert into stockImages
select '·ç¾°',bulkcolumn
from openrowset(bulk 'd:\\img.jpg',single_blob) as x
´´½¨´æ´¢¹ý³Ì£¬¼ìË÷ͼƬ£¬½«¶ ......
Ò».¹¤¾ßÏÂÔØ
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 ......
×òÌì¿´ÁËÆª²»ÊǺÜÑϽ÷µÄ²©ÎÄ¡¶Ò»¸öËãÃüС͵³ÌÐòµÄµ®Éú¡·£¬ÀïÃæÐ´ÁËÒ»¸öͨ¹ýAJAX͵ÇÔ±ðÈËÍøÕ¾Ëã·¨µÄ·½·¨¡£Êµ¼ùÁËһϸù±¾²»ÐУ¬AJAXËÆºõ²»ÄÜ¿çÓò¡£
ºóÀ´ÎÒÏëÁËһЩ½â¾ö·½·¨£¬ÖÕÓÚ¿çÓò³É¹¦¡£ÏÖÔÚ¹«²¼Ò»Ï·½·¨¡£
ÈÎÎñ£ºÔÚ×Ô¼ºÍøÕ¾×ö¸ö±íµ¥£¬Ïò¡ ......
$.get()ºÍ$.post()·½·¨
$.get(url [,data] [,callback] [,type])
type£ºstringÀàÐÍ£¬·þÎñÆ÷¶Ë·µ»ØÄÚÈݵĸñʽ£¬°üÀ¨xml£¬html£¬script£¬json£¬textºÍ_default
»Øµ÷º¯ÊýÖ»ÓÐÁ½¸ö²ÎÊý£ºfunction(data,textstatus){....}
data:·µ»ØµÄÄÚÈÝ £ ......
×î½üÔÚÓÃAjax×öµÇ¼´°¿Ú£¬µ«ÊÇlogoutµÄʱºòÐèÒª¶Ôsession½øÐд¦Àí¡£ÓõÄÊÇsession.removeAttribute()º¯Êý½øÐÐlogout¡£µ«ÊÇ£¬ÊÂʵ֤Ã÷£¬ÔÚlogoutÒÔºó£¬ÔٴεǼµÄʱºò£¬²¢²»Äܵǽ³É¹¦£¬Ñ¹¸ù²»»á½øÈëactionÖ´ÐÐÏàÓ¦µÄ·½·¨£¨hqlÓï¾äҲûÓÐÖ´ÐУ©¡£
Ϊ´Ë£¬¾Ý˵ÓÐÁ½ÖÖ·½·¨½ ......