jQuery Ajax È«½âÎö
jQueryȷʵÊÇÒ»¸öͦºÃµÄÇáÁ¿¼¶µÄJS¿ò¼Ü£¬ÄÜ°ïÖúÎÒÃÇ¿ìËٵĿª·¢JSÓ¦Ó㬲¢ÔÚÒ»¶¨³Ì¶ÈÉϸıäÁËÎÒÃÇдJavaScript´úÂëµÄÏ°¹ß¡£
·Ï»°ÉÙ˵£¬Ö±½Ó½øÈëÕýÌ⣬ÎÒÃÇÏÈÀ´¿´Ò»Ð©¼òµ¥µÄ·½·¨£¬ÕâЩ·½·¨¶¼ÊǶÔjQuery.ajax()½øÐзâ×°ÒÔ·½±ãÎÒÃÇʹÓõķ½·¨£¬µ±È»£¬Èç¹ûÒª´¦Àí¸´ÔÓµÄÂß¼£¬»¹ÊÇÐèÒªÓõ½jQuery.ajax()µÄ(Õâ¸öºóÃæ»á˵µ½).
1. load( url, [data], [callback] ) £ºÔØÈëÔ¶³Ì HTML Îļþ´úÂë²¢²åÈëÖÁ DOM ÖС£
url (String) : ÇëÇóµÄHTMLÒ³µÄURLµØÖ·¡£
data (Map) : (¿ÉÑ¡²ÎÊý) ·¢ËÍÖÁ·þÎñÆ÷µÄ key/value Êý¾Ý¡£
callback (Callback) : (¿ÉÑ¡²ÎÊý) ÇëÇóÍê³Éʱ(²»ÐèÒªÊÇsuccessµÄ)µÄ»Øµ÷º¯Êý¡£
Õâ¸ö·½·¨Ä¬ÈÏʹÓà GET ·½Ê½À´´«µÝµÄ£¬Èç¹û[data]²ÎÊýÓд«µÝÊý¾Ý½øÈ¥£¬¾Í»á×Ô¶¯×ª»»ÎªPOST·½Ê½µÄ¡£jQuery 1.2 ÖУ¬¿ÉÒÔÖ¸¶¨Ñ¡Ôñ·û£¬À´É¸Ñ¡ÔØÈëµÄ HTML Îĵµ£¬DOM Öн«½ö²åÈëɸѡ³öµÄ HTML ´úÂë¡£Óï·¨ÐÎÈç "url #some > selector"¡£
Õâ¸ö·½·¨¿ÉÒԺܷ½±ãµÄ¶¯Ì¬¼ÓÔØһЩHTMLÎļþ£¬ÀýÈç±íµ¥¡£
ʾÀý´úÂ룺
$(".ajax.load").load("http://www.csdn.net/",
function (responseText, textStatus, XMLHttpRequest){
this;//ÔÚÕâÀïthisÖ¸ÏòµÄÊǵ±Ç°µÄDOM¶ÔÏ󣬼´$(".ajax.load")[0]
//alert(responseText);//ÇëÇ󷵻صÄÄÚÈÝ
//alert(textStatus);//ÇëÇó״̬£ºsuccess£¬error
//alert(XMLHttpRequest);//XMLHttpRequest¶ÔÏó
});
2. jQuery.get( url, [data], [callback] )£ºÊ¹ÓÃGET·½Ê½À´½øÐÐÒì²½ÇëÇó²ÎÊý£ºurl (String) : ·¢ËÍÇëÇóµÄURLµØÖ·.data (Map) : (¿ÉÑ¡) Òª·¢Ë͸ø·þÎñÆ÷µÄÊý¾Ý£¬ÒÔ Key/value µÄ¼üÖµ¶ÔÐÎʽ±íʾ£¬»á×öΪQueryString¸½¼Óµ½ÇëÇóURLÖС£callback (Function) : (¿ÉÑ¡) ÔØÈë³É¹¦Ê±»Øµ÷º¯Êý(Ö»Óе±ResponseµÄ·µ»Ø״̬ÊÇsuccess²ÅÊǵ÷Óø÷½·¨)¡£ÕâÊÇÒ»¸ö¼òµ¥µÄ GET ÇëÇó¹¦ÄÜÒÔÈ¡´ú¸´ÔÓ $.ajax ¡£ÇëÇó³É¹¦Ê±¿Éµ÷Óûص÷º¯Êý¡£Èç¹ûÐèÒªÔÚ³ö´íʱִÐк¯Êý£¬ÇëʹÓà $.ajax¡£Ê¾Àý´úÂ룺 $.get("./Ajax.aspx", {Action:"get",Name:"lulu"}, function (data, textStatus){
//·µ»ØµÄ data ¿ÉÒÔÊÇ xmlDoc, jsonObj, html, text, µÈµÈ.
this; // ÔÚÕâÀïthisÖ¸ÏòµÄÊÇAjaxÇëÇóµÄÑ¡ÏîÅäÖÃÐÅÏ¢£¬Çë²Î¿¼ÏÂͼ
alert(data);
//alert(textStatus);//ÇëÇó״̬£ºsuccess£¬errorµÈµÈ¡£
µ±È»ÕâÀﲶ׽²»µ½error£¬ÒòΪerrorµÄʱºò¸ù±¾²»»áÔ
Ïà¹ØÎĵµ£º
×î½ü×ö¸öÈËÍøÕ¾Óöµ½AJAX¿ç×ÓÓòÃûµÄÎÊÌâ¡£
ż¶û¿´µ½baiduµÄͨÐÐÖ¤´¦Àí¶¼ÊÇÔÚ¶þ¼¶ÓòÃûpassport.baidu.comÖд¦ÀíµÄ£¬
µ«ÊÇbaiduºÜ¶àµØ·½µÇ¼¶¼ºÃÏñÊÇÓÃajax´¦ÀíµÄ£¬ËûÊÇÔõô×öµÄÄØ£¿Ñо¿ÁËһϣ¬·¢ÏÖÒ»¸öС¼¼ÇÉ¡£
²»·ÀÈôó¼ÒÒ²½è¼øһϡ£
ÔÚhttp://zhidao.baidu.com/ δµÇ¼Óû§»Ø´ðÎÊÌâʱ»áÓÃiframeµ÷ÓÃhttp://zhidao.bai ......
Ê×ÏÈҪ˵µÄ¾ÍÊÇ ajax ÊÇÎÞ·¨ÊµÏÖÉÏ´«ÎļþµÄ£¬¿ÉÒÔÏëÒ»ÏÂajaxÓëºǫ́ͨÐŶ¼ÊÇͨ¹ý´«µÝ×Ö·û´®£¬ÔõôÄÜ´«µÝÎļþÄØ£¿Æäʵ³öÓÚ°²È«¿¼ÂÇjsÊDz»ÄܲÙ×÷ÎļþµÄ£¬ËùÒԾͲ»ÒªÔÙ˵ÓÃajaxÀ´ÊµÏÖÎļþµÄÉÏ´«ÁË£¬ÕâÊDz»¿ÉÄܵġ£
¶ø±¾ÎÄʵÏÖµÄÎļþÉÏ´«Ò²ÊÇÎÞÒ³Ãæˢеģ¬¿ÉÒÔ˵ÊÇÒ»ÖÖ"ÀàËÆAJAX"·½·¨¡£
&n ......
JSP:
¿Î³ÌÃû³Æ:
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/options.js"></script>
<html:select property="icourseId" onchange="change(this)" style="width:180px;">
<html:opt ......
Background For the basic of how to create an AJAX enabled WCF service, please refer to MSDN: http://msdn.microsoft.com/en-us/library/bb924552.aspx. For the basic of JSONP, please refer to: http://en.wikipedia.org/wiki/JSON#JSONP. This article introduce how to make AJAX enabled WCF service support cr ......
Ç°ÑÔ£º
»ùÓÚuchomerµÄ²å¼þÈç¹ûûÓÐʹÓÃajax»òflex£¬¿ÉÒÔ˵ÎÞÂÛÈçºÎÒ²×ö²»µ½ÍêÃÀµÄ¡£¶øÏà±ÈÓÚflex£¬ajaxʹÓõĽ϶ࡣºÃ¶à²å¼þ¿ª·¢ÕßÔÚÑо¿
uchomeµÄajaxµÄʹÓùý³ÌÖл¨·ÑÁ˲»ÉÙʱ¼ä£¬´ËÎÄÒâÔÚ¼õÉÙ²å¼þ¿ª·¢ÕßµÄÑо¿Ê±¼ä¡£flexÏà¹Ø²å¼þµÄ˵Ã÷£¬¾´Çë¹Ø×¢£¡
´ËÎÄÕûÀí»¨Á˱¾Í¬Ñ§4¸öСʱÒÔÉϵÄʱ¼ä£¬Èç¹û°æÖ÷¾õµÃ¶Ô´ó¼ÒÓаïÖú£¬ ......