开发者

AJAX to post values without using any jquery file

I want to post the field values entered in this code to the page ajaxpost.php using Ajax and then do some operations there. What would be code required to be written in ajaxpost.php. Also woithout using any js file/jquery Here is the code of page in which fields are entered, I would like to know what would be the code to be written in ajaxpost.php

                 &开发者_JAVA百科lt;html>
         <head>
        <script type="text/javascript">
      function loadXMLDoc()
    {
       var xmlhttp;
     if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
             }
     else
       {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
       xmlhttp.onreadystatechange=function()
       {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
         {
      document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
          }
            }
             var zz=document.f1.dd.value;   //alert(zz);
            var qq= document.f1.cc.value;
         xmlhttp.open("POST","ajaxpost.php",true);
           xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
           xmlhttp.send("dd=zz&cc=qq");
     }
          </script>
        </head>
       <body>

     <h2>AJAX</h2>
  <form name="f1">
         <input type="text" name="dd">
        <input type="text" name="cc">
         <button type="button" onclick="loadXMLDoc()">Request data</button>
         <div id="myDiv"></div>
    </form>
        </body>
           </html>


I think you are looking for bare bones php and ajax for which there are tons of tutorials such as this one, which is quite close to what you are looking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜