Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

jquery AjaxÏê½â

²ÎÊý:
options
·µ»ØÖµ:
XMLHttpRequest
ʹÓÃHTTPÇëÇóÒ»¸öÒ³Ãæ¡£
ÕâÊÇjQueryµÄµÍ¼¶AJAXʵÏÖ¡£Òª²é¿´¸ß¼¶³éÏ󣬼û$.set¡¢$.postµÈ£¬ÕâЩ·½·¨¸üÒ×ÓÚÀí½âºÍʹÓᣵ«Êǹ¦ÄÜÉÏÓÐÏÞÖÆ(ÀýÈ磬ûÓдí
Îó´¦Àíº¯Êý)¡£
¾¯¸æ£ºÈç¹ûÊý¾ÝÀàÐÍÖ¸¶¨Îª"script"£¬ÄÇôPOST×Ô¶¯×ª»¯ÎªGET·½·¨¡£(ÒòΪscript»á×÷Ϊһ¸öǶÈëÒ³ÃæµÄscript±êÇ©½øÐÐÔØ
Èë)
$.ajax()º¯Êý·µ»ØËü´´½¨µÄXMLHttpRequest¶ÔÏó¡£Ôڴ󲿷ÖÇé¿öÏ£¬Äã²»ÐèÒªÖ±½Ó²Ù×÷´Ë¶ÔÏó¡£Í¨³££¬Õâ¸ö
XMLHttpRequest¶ÔÏóÖ÷ÒªÓÃÓÚÐèÒªÊÖ¶¯ÖжÏXMLHttpRequestÇëÇóµÄʱºò¡£
×¢Ò⣺Èç¹ûÄãÖ¸Ã÷ÁËÏÂÃæÁгöµÄÊý¾ÝÀàÐÍ£¬ÇëÈ·±£·þÎñ¶Ë·¢ËÍÁËÕýÈ·µÄMIMEÏìÓ¦ÀàÐÍ(Èç. xml µÄÀàÐÍÊÇ
"text/xml")¡£´íÎóµÄMIMEÀàÐÍÄܹ»µ¼Ö½ű¾³öÏÖÒâÏë²»µ½µÄÎÊÌâ¡£Çë²é¿´AJAXµÄ·¶ÀýÀ´Á˽âÊý¾ÝÀàÐ͵ĸü¶àÐÅÏ¢¡£
$.ajax()º¯ÊýÐèÒªÒ»¸ö²ÎÊý£¬Ò»¸ö°üº¬Óмü/Öµ¶ÔµÄ¶ÔÏó£¬ÓÃÓÚ³õʼ»¯²¢²Ù×÷ÇëÇó¶ÔÏó¡£
ÔÚjQuery 1.2°æ±¾ÖУ¬Èç¹ûÄãÖ¸Ã÷ÁËÒ»¸öJSONP»Øµ÷º¯Êý£¬Äã¾Í¿ÉÒÔ´ÓÆäËüµÄÓòÖÐÔØÈëJSONÀàÐ͵ÄÊý¾Ý£¬Ð´·¨ÀàËÆÓÚ
"myurl?callback=?"
¡£jQuery»á×Ô¶¯µ÷ÓÃÕýÈ·µÄ·½·¨Ãû³ÆÀ´´úÌæ²éѯ×Ö·û´®£¬Ö´ÐÐÄãÖ¸¶¨µÄ»Øµ÷º¯Êý¡£»òÕߣ¬ÄãÒ²¿ÉÒÔÖ¸¶¨jsonpµÄÊý¾ÝÀàÐ͵Ļص÷º¯Êý£¬´Ëº¯Êý»á×Ô¶¯Ìí¼Ó
µ½AjaxÇëÇóÖС£
²ÎÊýÑ¡Ïî:
async(true) Êý¾ÝÀàÐÍ: Boolean
ĬÈÏÇé¿öÏ£¬ËùÓеÄÇëÇó¶¼ÊÇÒì²½·¢Ë͵Ä(ĬÈÏΪtrue)¡£ Èç¹ûÐèÒª·¢ËÍͬ²½ÇëÇó,
ÉèÖÃÑ¡ÏîΪfalse¡£×¢Ò⣬ͬ²½ÇëÇó¿ÉÄÜ»áÔÝʱµÄËø¶¨ä¯ÀÀÆ÷, µ±ÇëÇ󼤻îʱ²»ÄܽøÐÐÈκβÙ×÷¡£
beforeSend Êý¾ÝÀàÐÍ: Function
Ò»¸öÔ¤´¦Àíº¯ÊýÓÃÓÚÔÚ·¢ËÍÇ°ÐÞ¸ÄXMLHttpRequest¶ÔÏó£¬ÉèÖÃ×Ô¶¨ÒåÍ·²¿µÈ¡£
XMLHttpRequest×÷ΪΩһµÄ²ÎÊý±»´«µÝ¡£ÕâÊÇÒ»¸ö Ajax ʼþ¡£
function (XMLHttpRequest) {
this; // the options for this ajax request
}
cache(true) Êý¾ÝÀàÐÍ: Boolean
jQuery 1.2ÖÐÐÂÌí¼ÓµÄ²ÎÊý, Èç¹ûÉèΪfalse£¬Ôò»áÇ¿ÖÆä¯ÀÀÆ÷²»»º´æÇëÇóµÄÒ³Ãæ¡£
complete Êý¾ÝÀàÐÍ: Function
µ±ÇëÇóÍê³ÉʱִÐеĺ¯Êý(Ôڳɹ¦»òʧ°ÜÖ®ºóÖ´ÐÐ)¡£Õâ¸öº¯ÊýÓÐ2¸ö²ÎÊý:
XMLHttpRequest¶ÔÏóºÍÒ»¸öÃèÊöHTTPÏàÓ¦µÄ״̬×Ö·û´®¡£ ÕâÊÇÒ»¸ö Ajax ʼþ¡£
function (XMLHttpRequest, textStatus) {
this; // the options for this ajax request
}
contentType("application/x-www-form-urlencoded") Êý¾ÝÀàÐÍ: String
·¢Ë͵½·þÎñÆ÷µÄÊý¾ÝµÄÄÚÈÝÀàÐÍ¡£Ä¬ÈÏÊÇ "


Ïà¹ØÎĵµ£º

AjaxµÄÔ­ÀíºÍÓ¦ÓÃ

¹ØÓÚajaxµÄÃû×Ö
    ajax µÄÈ«³ÆÊÇAsynchronous JavaScript and XML£¬ÆäÖУ¬Asynchronous ÊÇÒì²½µÄÒâ˼£¬ËüÓбðÓÚ´«Í³web¿ª·¢ÖвÉÓõÄͬ²½µÄ·½Ê½¡£
¹ØÓÚͬ²½ºÍÒì²½
 
Òì²½´«ÊäÊÇÃæÏò×Ö·ûµÄ´«Ê䣬ËüµÄµ¥Î»ÊÇ×Ö·û£»¶øͬ²½´«ÊäÊÇÃæÏò±ÈÌصĴ«Ê䣬ËüµÄµ¥Î»ÊÇè壬Ëü´«ÊäµÄʱºòÒªÇó½ÓÊÜ·½ºÍ·¢ËÍ·½µÄʱÖÓÊ ......

дһ¸öajax funciton

function Ajax(url)
{
var m_xmlReq=null;
if(window.ActiveXObject)
{
try
{
m_xmlReq = new ActiveXObject('Msxml2.XMLHTTP');
}
catch(e)
{
try{m_xmlReq = new ActiveXObject('Microsoft.XMLHTTP');}catch(e){}
}
}
else if(window.XMLHttpRequest ......

AJAX (Òì²½ JavaScript ºÍ XML)

AJAX (Òì²½ JavaScript ºÍ XML) ÊǸöвúÉúµÄÊõÓï,רΪÃèÊöJavaScriptµÄÁ½ÏîÇ¿´óÐÔÄÜ.ÕâÁ½ÏîÐÔ
ÄÜÔÚ¶àÄêÀ´Ò»Ö±±»ÍøÂ翪·¢ÕßËùºöÂÔ,Ö±µ½×î½üGmail, Google suggestºÍgoogle MapsµÄºá¿Õ³öÊÀ²ÅʹÈË
ÃÇ¿ªÊ¼Òâʶµ½ÆäÖØÒªÐÔ.
ÕâÁ½Ïî±»ºöÊÓµÄÐÔÄÜÊÇ:
* ÎÞÐèÖØÐÂ×°ÔØÕû¸öÒ³Ãæ±ãÄÜÏò·þÎñÆ÷·¢ËÍÇëÇó.
* ¶ÔXMLÎĵµµÄ½âÎöºÍ´¦Àí£® ......

ajax»º´æÎÊÌâ½â¾ö;¾¶

ÎÒÓÃPHPºÍAjax½áºÏ£¬Ìí¼ÓÊý¾ÝÖ®ºó£¬Ë¢ÐÂǰ̨ҳÃ棬Êý¾ÝûÓб仯¡£
ÎҸĶ¯PHP¶¯Ì¬½Å±¾£¬Ö»ÓÐÖØÐÂÕÒ¿ªIEÔÙÊäÈëµØÖ·£¬²ÅÄÜ¿´µ½Ð§¹û¡£
ÒÔÉÏÕâЩÊDz»ÊÇ»º´æµÄÔ­Òò°¡£¿Ôõô½â¾ö£¿
ajax»º´æÎÊÌâ½â¾ö;¾¶£º
ÊÇ»º´æµÄÎÊÌâ¡£
ÔÚ·þÎñ¶Ë¼Ó header("Cache-Control: no-cache, must-revalidate");
²¢ÇÒÔÚÄãµÄJSÌá½»²ÎÊýÖмÓËæ»ú» ......

ajaxÓëjQuery·½·¨

ajax.asp
ÏÖÔÚʱ¼äÊÇ< %=Now()%>
ajax.html
<script type="text/javascript">
function Ajax(){
var xmlHttp=null;
if(window.ActiveXObject){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ