ajax»ù´¡¶ÁÊé±Ê¼Ç µÚÒ»ÕÂ
1¡¢XMLHttpRequest¶ÔÏóµÄ´´½¨
ÓÉÓÚ ²»ÊÇw3c±ê×¼£¬ËùÒÔʹÓÃJavascript´´½¨Ö®µÄ·½·¨Ò²²»Í¬£¡Internet explorer °ÑXMLHttpRequestʵÀý»¯Îª ActiveX¿Ø¼þ£¬È»¶ø ÆäËûµÄä¯ÀÀÆ÷£¨FireFox£¬opera£©°ÑXMLHttpRequestʵÀý»¯Îª±¾µØµÄJavaScriptÒ»¸ö¶ÔÏó
ËùÒÔ Ö»ÒªÈ·¶¨ÊÇ·ñ Ö§³Ö ActiveX¿Ø¼þ¶ÔÏ󣡣¡Èç¹ûÖ§³ÖÔò´´½¨ActiveX¿Ø¼þ£¡ Èç¹û²»Ö§³Ö£¬Ôò´´½¨ ±¾µØµÄJavascript¶ÔÏó
ÏÂÃæÒ»¸ö´úÂ룺
var xmlHttp£»
function createXMLHttpRequest£¨£©
{
if(window.ActiveXObject) //ÔòʹÓõÄÊÇInternet explorer ä¯ÀÀÆ÷
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest)
xmlHttp=new XMLHttpRequest();
}
2 XMLHttpRequest ¶ÔÏóµÄ·½·¨
Ò»£ºopen(String method ,String URL,boolean )
method ÊDZíʾ Ìá½»Êý¾ÝµÄ·½·¨£ºget post put
URLÊÇÌá½»µÄÍøÖ·
ÏÂÃæµÄBoolean ÊÇ·ñÉèÖÃΪÒì²½£¬Ò»°ã ÉèÖÃΪtrue ÒòΪÕâÕýÊÇ AjaxµÄÌس¤
Èç¹ûÕâ¸ö²ÎÊýÉèÖÃΪfalse ÄÇ´¦ÀíµÄÇëÇó»áÒ»Ö±µÈ´ý£¬ÖªµÀÔ¶³ÌµÄ·þÎñÆ÷·µ»ØÏìÓ¦£¡£¡
¶þ; send (content)
Ïò·þÎñÆ÷·¢ËÍÇëÇó¡£Èç¹û±»ÉùÃ÷Ϊ Òì²½µÄ ¡£ÄÇËû»áÁ¢¼´·µ»Ø£¡·ñÔòÖªµÀ ·þÎñÆ÷ ·µ»ØÏìÓ¦
²ÎÊý¿ÉѡΪ DOMµÄʵÀý¶ÔÏó ×Ö·û´® Á÷
Èý£º
setRequestHeader£¨String Header£¬String Value£©
ÉèÖÃhttpÇëÇó
ËÄ;
abort()ÖÕÖ¹ÇëÇó
Îå:
getAllResponseHeaders()
·µ»ØËùÓÐÏìÓ¦µÄÊײ¿
getAllResponseHeader(String name)
ÁíÍ⻹ÓÐЩÊôÐÔ
onreadystatechange
ÿ¸ö״̬¸Ä±äʱ¶¼»á´¥·¢Õâ¸öʼþ´¦ÀíÆ÷£¬Í¨³£»áµ÷ÓÃÒ»¸öJavaScriptº¯Êý£¨¿ÉÒÔ×Ô¶¨Ò壩
readyState
ÇëÇóµÄ״̬¡£ÓÐ5¸ö¿ÉÈ¡Öµ£º0 = δ³õʼ»¯£¬1 = ÕýÔÚ¼ÓÔØ£¬2 = ÒѼÓÔØ£¬3 = ½»»¥ÖУ¬4 = Íê³É
responseText
·þÎñÆ÷µÄÏìÓ¦£¬±íʾΪһ¸ö´®
responseXML
·þÎñÆ÷µÄÏìÓ¦£¬±íʾΪXML¡£Õâ¸ö¶ÔÏó¿ÉÒÔ½âÎöΪһ¸öDOM¶ÔÏó
status
·þÎñÆ÷µÄHTTP״̬Â루200¶ÔÓ¦OK£¬404
Ïà¹ØÎĵµ£º
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 ......
ÎÒÓÃPHPºÍAjax½áºÏ£¬Ìí¼ÓÊý¾ÝÖ®ºó£¬Ë¢ÐÂǰ̨ҳÃ棬Êý¾ÝûÓб仯¡£
ÎҸĶ¯PHP¶¯Ì¬½Å±¾£¬Ö»ÓÐÖØÐÂÕÒ¿ªIEÔÙÊäÈëµØÖ·£¬²ÅÄÜ¿´µ½Ð§¹û¡£
ÒÔÉÏÕâЩÊDz»ÊÇ»º´æµÄÔÒò°¡£¿Ôõô½â¾ö£¿
ajax»º´æÎÊÌâ½â¾ö;¾¶£º
ÊÇ»º´æµÄÎÊÌâ¡£
ÔÚ·þÎñ¶Ë¼Ó header("Cache-Control: no-cache, must-revalidate");
²¢ÇÒÔÚÄãµÄJSÌá½»²ÎÊýÖмÓËæ»ú» ......
Web 2.0 һƳ
ÔÚÉîÈëÑо¿´úÂë֮ǰÊ×ÏÈ¿´¿´×î½üµÄ¹Ûµã —— Ò»¶¨ÒªÊ®·ÖÇå³þ Web 2.0 Õâ¸ö¸ÅÄî¡£Ìýµ½ Web 2.0 Õâ¸ö´ÊµÄʱºò£¬Ó¦¸ÃÊ×ÏÈÎÊÒ»ÎÊ “Web 1.0 ÊÇʲô£¿” ËäÈ»ºÜÉÙÌýÈËÌáµ½ Web 1.0£¬Êµ¼ÊÉÏËüÖ¸µÄ¾ÍÊǾßÓÐÍêÈ«²»Í¬µÄÇëÇóºÍÏìӦģÐ͵Ĵ«Í³ Web¡£±ÈÈ磬µ½ Amazon.com ÍøÕ¾Éϵã»÷Ò»¸ö°´Å¥»òÕßÊäÈë ......
Ajax½éÉÜ
AJAX - ä¯ÀÀÆ÷Ö§³Ö
AJAX µÄÒªµãÊÇ XMLHttpRequest ¶ÔÏó¡£²»Í¬µÄä¯ÀÀÆ÷´´½¨ XMLHttpRequest ¶ÔÏóµÄ·½·¨ÊÇÓвîÒìµÄ¡£IE ä¯ÀÀÆ÷ʹÓà ActiveXObject£¬¶øÆäËûµÄä¯ÀÀÆ÷ʹÓÃÃûΪ XMLHttpRequest µÄ JavaScript ÄÚ½¨¶ÔÏó¡£ÈçÐèÕë¶Ô²»Í¬µÄä¯ÀÀÆ÷À´´´½¨´Ë¶ÔÏó£¬ÎÒÃÇҪʹÓÃÒ»Ìõ "try and catch" Óï¾ä¡£
<script type="t ......
ÔÚʹÓÃAJAX½øÐгÌÐò¿ª·¢µÄʱºò£¬Ò»Ö±¶¼»áÃæ¶ÔÒ»¸ö»º´æµÄÎÊÌ⣡£¡
¼´ÊÇ£¬ÉÏ´ÎÇëÇóµÄʱºò£¬ÒòΪÄãµÄSQLÓï¾ä»òÕßÆäËûÔÒò£¬webserviceÖзµ»ØֵΪ¿Õ£¬²»ÊÇÄãÏëÒªµÄ½á¹û¼¯£¬ÔÚÄã·¢ÏÖwebserviceÖÐÓï¾äÌå³ö´íºó£¬½øÐÐÐ޸ģ¬ÖØвâÊÔ£¬ÈÔÈ»ÊÇÉϴεķµ»Ø½á¹û£¡¸Ð¾õ¾ÍÏñÄãµÄÐÞ¸ÄÍêÈ«ÎÞЧ¡£¡£
Æäʵ£¬ÕâÊÇÔÚAJAXµ ......