jquery AJAXÓ¦ÓÃ
load(url[,data][,callback])------------->ͨ³£ÓÃÀ´´ÓWEB·þÎñÆ÷ÉÏ»ñÈ¡¾²Ì¬µÄÊý¾ÝÎļþ
url: stringÀàÐÍ ÇëÇóHTMLÒ³ÃæµÄURLµØÖ·
data(¿ÉÑ¡): object ·¢ËÍÖÁ·þÎñÆ÷µÄkey/valueÊý¾Ý
callback(¿ÉÑ¡):function ÇëÇóÍê³Éʱ»Øµ÷º¯Êý
Àý×Ó£º
Ö÷Ò³Ãæ´úÂ룺
<style type="text/css">
* { margin:0; padding:0;}
body { font-size:12px;}
.comment { margin-top:10px; padding:10px; border:1px solid #ccc;background:#DDD;}
.comment h6 { font-weight:700; font-size:14px;}
.para { margin-top:5px; text-indent:2em;background:#DDD;}
</style>
$(function(){
$("#send").click(function(){
$("#resText").load("test.html .para",function (responseText, textStatus, //test.html .paraΪtest.htmlÖÐ.classΪparaµÄÄÚÈÝXMLHttpRequest){
alert( $(this).html() ); //ÔÚÕâÀïthisÖ¸ÏòµÄÊǵ±Ç°µÄDOM¶ÔÏ󣬼´ $("#iptText")[0]
alert(responseText); //ÇëÇ󷵻صÄÄÚÈÝ
alert(textStatus); //ÇëÇó״̬£ºsuccess£¬error
alert(XMLHttpRequest); //XMLHttpRequest¶ÔÏó
});
})
})
<input type="button" id="send" value="Ajax»ñÈ¡" />
<div class="comment">
ÒÑÓÐÆÀÂÛ£º
</div>
<div id="resText" >
Ïà¹ØÎĵµ£º
ajax¿çÓòºÍJSµÄ¿çÓòͨÐÅ(Cross The Site)µÄ¼¸ÖÖ½â¾ö·½°¸
×î½ü×öµÄÒ»¸öÏîÄ¿ÖÐÐèÒªajax¿çÓòÈ¡µÃÊý¾Ý,Èç¹ûÊÇÔÚ±¾ÓòÖÐȷʵûÓÐÎÊÌ⣬µ«ÊǷŵ½¶þ¼¶ÓòºÍÆäËûÓòÏÂä¯ÀÀÆ÷Ö±½Ó¾Íµ¯³öÌáʾ¿ò:“¸ÃÒ³ÕýÔÚ
1.ʲôÒýÆðÁËajax¿çÓò²»ÄܵÄÎÊÌâ
ajax±¾Éíʵ¼ÊÉÏÊÇͨ¹ýXMLHttpRequest¶ÔÏóÀ´½øÐÐÊý¾ÝµÄ½»»¥£¬¶øä¯ÀÀÆ÷ ......
jQuery ÊÇÒ»¸öJavaScript ¿â£¬ËüÓÐÖúÓÚ¼ò»¯ JavaScript™ ÒÔ¼° Asynchronous JavaScript + XML (Ajax) ±à³Ì¡£ÓëÀàËÆµÄ JavaScript ¿â²»Í¬£¬jQuery ¾ßÓжÀÌØµÄ»ù±¾ÔÀí£¬¿ÉÒÔ¼ò½àµØ±íʾ³£¼ûµÄ¸´ÔÓ´úÂ롣ѧϰ jQuery »ù±¾ÔÀí£¬Ì½Ë÷ÆäÌØÐԺ͹¦ÄÜ£¬Ö´ÐÐһЩ³£¼ûµÄ Ajax ÈÎÎñ²¢ÕÆÎÕÈçºÎʹÓòå¼þÀ©Õ¹ jQuery¡£
jQuery ÊÇʲ ......
ͨ¹ýÀí½â´íÎóµÄ±àÂ뷽ʽ£¬¿ÉÒÔ¸üºÃµØÁ˽âÈçºÎÕýÈ·µØ½øÐбàÂë¡£µ±È»£¬±àд Asynchronous JavaScript™ +
XML£¨Ajax£©ÓÐÕýÈ·µÄ·½·¨£¬Ò²ÓдíÎóµÄ·½·¨¡£±¾ÎĽ«ÌÖÂÛһЩÐèÒª±ÜÃâµÄ³£¼û±àÂëʵ¼ù¡£
Èç¹ûÈËÃÇÔÚµÚÒ»´Î¾ÍÄܹ»½«ËùÓÐÊÂÇéÈ«²¿×ö¶Ô£¬ÄÇôÕâ¸öÊÀ½ç½«±äµÃÍêÈ«²»Í¬¡£Ajax Ò²ÊÇÈç´Ë¡£ÎÒ×öÁË´óÁ¿µÄ¹¤×÷ÒÔÖ§³Ö Ajax
......
ÎÊÌ⣺
µ±Óû§µã»÷ɾ³ý°´Å¥Ê±£¬³ÌÐòµ÷ÓÃResponse.write("<script>alert('ÊÇ·ñ¼ÌÐø')</script>")ÊÇÒ³Ãæ»áµ¯³ö´íÎó£º
Sys.WebForms.PageRequestManagerParserErrorException:The
message received from the server count not be parsed.Common causes for
this error are when ......
AjaxµÄÈ«³ÆÊÇ£ºAsynchronousJavaScript+XML
2.AjaxµÄ¶¨Ò壺
Ajax²»ÊÇÒ»¸ö¼¼Êõ£¬Ëüʵ¼ÊÉÏÊǼ¸ÖÖ¼¼Êõ£¬Ã¿ÖÖ¼¼Êõ¶¼ÓÐÆä¶ÀÌØÕâ´¦£¬ºÏÔÚÒ»Æð¾Í³ÉÁËÒ»¸ö¹¦ÄÜÇ¿´óµÄм¼Êõ¡£
3.Ajax°üÀ¨£º
XHTMLºÍCSS
ʹÓÃÎĵµ¶ÔÏóÄ£ÐÍ(DocumentObjectModel)×÷¶¯Ì¬ÏÔʾºÍ½»»¥
ʹÓÃXMLºÍXSLT×öÊý¾Ý½»»¥ºÍ²Ù×÷
ʹÓÃXMLHttpRequest½øÐÐÒ ......