AJax¼¼Êõ

AJAX½Ì³Ì(6)£ºAJAX - ÇëÇó·þÎñÆ÷

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2018-04-23 08:00 ÎÒÒªÆÀÂÛ( )

AJAX½Ì³Ì(6)£ºAJAX - ÇëÇó·þÎñÆ÷,AJAX - Ïò·þÎñÆ÷·¢ËÍÒ»¸öÇëÇó,ÒªÏë°ÑÇëÇó·¢Ë͵½·þÎñÆ÷£¬ÎÒÃǾÍÐèҪʹÓà open() ·½·¨ºÍ send() ·½·¨¡£

ÍøÒ³ÖÆ×÷WebjxÎÄÕ¼ò½é£ºAJAX - Ïò·þÎñÆ÷·¢ËÍÒ»¸öÇëÇó,ÒªÏë°ÑÇëÇó·¢Ë͵½·þÎñÆ÷£¬ÎÒÃǾÍÐèҪʹÓà open() ·½·¨ºÍ send() ·½·¨¡£

AJAX - Ïò·þÎñÆ÷·¢ËÍÒ»¸öÇëÇó

ÒªÏë°ÑÇëÇó·¢Ë͵½·þÎñÆ÷£¬ÎÒÃǾÍÐèҪʹÓà open() ·½·¨ºÍ send() ·½·¨¡£

open() ·½·¨ÐèÒªÈý¸ö²ÎÊý¡£µÚÒ»¸ö²ÎÊý¶¨Òå·¢ËÍÇëÇóËùʹÓõķ½·¨£¨GET »¹ÊÇ POST£©¡£µÚ¶þ¸ö²ÎÊý¹æ¶¨·þÎñÆ÷¶Ë½Å±¾µÄ URL¡£µÚÈý¸ö·½·¨¹æ¶¨Ó¦µ±¶ÔÇëÇó½øÐÐÒì²½µØ´¦Àí¡£

send() ·½·¨¿É½«ÇëÇóËÍÍù·þÎñÆ÷¡£Èç¹ûÎÒÃǼÙÉè HTML ÎļþºÍ ASP ÎļþλÓÚÏàͬµÄĿ¼£¬ÄÇô´úÂëÊÇÕâÑùµÄ£º

xmlHttp.open("GET","time.asp",true); xmlHttp.send(null);

ÏÖÔÚ£¬ÎÒÃDZØÐë¾ö¶¨ºÎʱִÐÐ AJAX º¯Êý¡£µ±Óû§ÔÚÓû§ÃûÎı¾¿òÖмüÈëijЩÄÚÈÝʱ£¬ÎÒÃÇ»áÁÊý“ÔÚÄ»ºó”Ö´ÐС£

<html> <body> <script type="text/javascript"> function ajaxFunction() { var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("ÄúµÄä¯ÀÀÆ÷²»Ö§³ÖAJAX£¡"); return false; } } } xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { document.myForm.time.value=xmlHttp.responseText; } } xmlHttp.open("GET","time.asp",true); xmlHttp.send(null); } </script> <form name="myForm"> Óû§: <input type="text" name="username" onkeyup="ajaxFunction();" /> ʱ¼ä: <input type="text" name="time" /> </form> </body> </html>

ÏÂÒ»½Ú½éÉÜ "time.asp" µÄ½Å±¾£¬ÕâÑùÎÒÃÇÍêÕûµÄ AJAX Ó¦ÓóÌÐò¾Í¸ã¶¨ÁË¡£

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • JAVA AJAX½Ì³ÌµÚ¶þÕÂ-JAVASCRIPT»ù´¡ÖªÊ¶(2)

    JAVA AJAX½Ì³ÌµÚ¶þÕÂ-JAVASCRIPT»ù´¡ÖªÊ¶(2)

    2018-03-29 11:00

  • JAVA AJAX½Ì³ÌµÚÒ»Õ¡ª³õʶAJAX

    JAVA AJAX½Ì³ÌµÚÒ»Õ¡ª³õʶAJAX

    2018-03-11 11:00

  • AJAX AJAX½Ì³Ì AJAXʵÀý(4)

    AJAX AJAX½Ì³Ì AJAXʵÀý(4)

    2017-12-11 15:17

  • AJAX AJAX½Ì³Ì AJAXʵÀý(3)

    AJAX AJAX½Ì³Ì AJAXʵÀý(3)

    2017-12-01 08:38

ÍøÓѵãÆÀ
·