AJax¼¼Êõ

AJAXÒ첽ѧϰ×ܽᣨ1£©(2)

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2017-10-25 13:04 ÎÒÒªÆÀÂÛ( )

Ïà¹ØµÄajax²Ù×÷JSÎļþ document.getElementById("search").onclick = function() {var request = new XMLHttpRequest();request.open("GET", "server.php?number=" + document.getElementById("keyword").value);re

Ïà¹ØµÄajax²Ù×÷JSÎļþ

document.getElementById("search").onclick = function() { var request = new XMLHttpRequest(); request.open("GET", "server.php?number=" + document.getElementById("keyword").value); request.send(); request.onreadystatechange = function() { if (request.readyState===4) { if (request.status===200) { document.getElementById("searchResult").innerHTML = request.responseText; } else { alert("·¢Éú´íÎó£º" + request.status); } } } } document.getElementById("save").onclick = function() { var request = new XMLHttpRequest(); request.open("POST", "server.php"); //´Ë´¦Òª°Ñ¸÷¸öÊäÈë¿ò»ñÈ¡µ½µÄ¸÷¸öÔ±¹¤ÐÅÏ¢Ò»URLµÄ·½Ê½À¦°óµ½dataÖÐ var data = "name=" + document.getElementById("staffName").value + "&number=" + document.getElementById("staffNumber").value + "&sex=" + document.getElementById("staffSex").value + "&job=" + document.getElementById("staffJob").value; request.setRequestHeader("Content-type","application/x-www-form-urlencoded"); request.send(data); request.onreadystatechange = function() { if (request.readyState===4) { if (request.status===200) { document.getElementById("createResult").innerHTML = request.responseText; //ʵʱ¸üÐÂÊäÈë¿òÊäÈëÄÚÈݺóµÃµ½µÄ½á¹û } else { alert("·¢Éú´íÎó£º" + request.status); } } } }

ÐèÒªÌرð×¢Ò⣬²»ÒªÍü¼ÇÉèÖÃcontent-type

request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
²Ù×÷½á¹ûʾÒâͼ

ͼƬÃèÊö


±¾ÎÄÓɱ¾ÈË×ܽá×ÔĽ¿ÎÍø@WayneJµÄajaxÈ«½Ó´¥¿Î³ÌÁ´½ÓÃèÊö£¬´úÂëÓë½Øͼ·ÇÔ­´´£¬½ö¹©Ñ§Ï°£¬ÈçÓÐÇÖȨÇë˽ПæÖª¡£

42 ÈËÍƼö

  • ·ÖÏíµ½

    ÆÀÂÛ

    ÊÕ²Ø

  • ÆÀÂÛ£¨Enter+Ctrl£©

    ÈÈÃÅÆÀÂÛ

    ÆÀÂÛ¼ÓÔØÖÐ...

    ÌõÆÀÂÛ

    ÆÀÂÛ¼ÓÔØÖÐ...

    ¡¡

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

    Ïà¹ØÎÄÕÂ
    • AJAXÏà¹Ø֪ʶ×ܽá

      AJAXÏà¹Ø֪ʶ×ܽá

      2017-10-25 16:20

    • ajax¿ÉÒÔ×öʲôÊ×Ò³

      ajax¿ÉÒÔ×öʲôÊ×Ò³

      2017-10-24 15:22

    • 10AT±äËÙÏäÀ´ÁË£¡ 2019¿î¿ÆÂõÂÞµýÕÕÆعâ

      10AT±äËÙÏäÀ´ÁË£¡ 2019¿î¿ÆÂõÂÞµýÕÕÆعâ

      2017-10-24 15:20

    • Web 2.0¿ª·¢¼¼ÊõÏê½â¡·(ÍõÅæ//·ëÂü·Æ)¡¾ÕªÒª

      Web 2.0¿ª·¢¼¼ÊõÏê½â¡·(ÍõÅæ//·ëÂü·Æ)¡¾ÕªÒª

      2017-10-23 18:00

    ÍøÓѵãÆÀ
    º