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
´´½¨´æ´¢¹ý³Ì£¬¼ìË÷ͼƬ£¬½«¶ ......
jQuery ÊÇʲô£¿
Çë·ÃÎÊ Ajax ¼¼Êõ×ÊÔ´ÖÐÐÄ£¬ÕâÊÇÓÐ¹Ø Ajax ±à³ÌÄ£ÐÍÐÅÏ¢µÄһվʽÖÐÐÄ£¬°üÀ¨ºÜ¶àÎĵµ¡¢½Ì³Ì¡¢ÂÛ̳¡¢blog¡¢wiki ºÍÐÂÎÅ¡£ÈκΠAjax µÄÐÂÐÅÏ¢¶¼ÄÜÔÚÕâÀïÕÒµ½¡£
jQuery ÓÉ John Resig ´´½¨ÓÚ 2006 Äê³õ£¬¶ÔÓÚÈκÎʹÓà JavaScript ´úÂëµÄ³ÌÐòÔ±À´Ëµ£¬ËüÊÇÒ»¸ö·Ç³£ÓÐÓÃµÄ JavaScript ¿â¡£ÎÞÂÛÄúÊǸոսӴ¥ Java ......
´úÂëÏÂÔØ£ºhttp://code.google.com/p/ajaxautocomplete/downloads/list
Auto CompleteµÄjQuery¿Ø¼þ¡£
Ê×ÏÈÊÇÐèÒªÉè¼ÆÏÂÎÒÃǵÄDIV×îºóÓ¦¸ÃÏÔʾ³ÉʲôÑù×Ó,ÎÒµÄCSS²»Õ¦µØ¡£Ï¹ÍæÄØ¡£Ñù×ÓÈçÏ£º
Ê×ÏÈÊÇÒ»¸öDIV£¬È»ºóÊÇÌí¼ÓÒ»¸öulºÍ¼¸¸öli tag:
<div id="nav">
<ul>
<li><a>Text1 field1& ......
ajaxÇëÇó²»·µ»Øhtml´úÂëµÄÈýÖÖ·½Ê½
ajaxÇëÇó´úÂ룺
function ajaxSend() {
$.ajax({
url: “Test_Ajax.aspx”,
type: “post”,
data: { name: “ajax” },//Èç¹ûÇëÇóµÄ×ÔÉíÒ³Ã棬ΪÁËÔÚºǫ́ÅжÏÊDz»ÊÇajaxÇëÇó
error: function(xhr, textStatus, errorThown) {
alert(errorThown) ......
1¡¢ajax¼¼ÊõµÄ±³¾°
²»¿É·ñÈÏ£¬ajax¼¼ÊõµÄÁ÷ÐеÃÒæÓÚgoogleµÄ´óÁ¦Íƹ㣬ÕýÊÇÓÉÓÚgoogle earth¡¢google suggestÒÔ¼°gmailµÈ¶Ôajax¼¼ÊõµÄ¹ã·ºÓ¦Ó㬴ßÉúÁËajaxµÄÁ÷ÐС£¶øÕâÒ²ÈÃ΢Èí¸Ðµ½ÎޱȵÄÞÏÞΣ¬ÒòΪÔçÔÚ97Ä꣬΢Èí±ãÒѾ·¢Ã÷ÁËajaxÖеĹؼü¼¼Êõ£¬²¢ÇÒÔÚ99ÄêIE5ÍƳö֮ʱ£¬Ëü±ã¿ªÊ¼Ö§³ÖXmlH ......