0

我有一个像这样的个人资料创建页面。

<html>
    <head>
        <script>
            function validateMe(){

               var xmlhttp;
               var userEmail = document.getElementById("email").value;
               var userPwd = document.getElementById("pwd").value;
               //alert(userEmail);
                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)
                    {
                        //alert(xmlhttp.responseText);
                    }
                    document.getElementById("responds").innerHTML=xmlhttp.responseText;
                    }

                xmlhttp.open("POST","api.php?email="+userEmail+"&pwd="+userPwd,true);
                xmlhttp.send();  
            }
        </script>
    </head>
    <body>
        <form name="login" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
            <table>
                <tr><td colspan="2">Login</td></tr>
                <tr><td>Username:</td><td><input type="text" name="email" id="email"/></td></tr>
                <tr><td>Password:</td><td><input type="text" name="pwd" id="pwd"/></td></tr>
                <tr><td><input type="button" value="Submit" name="submit" onclick="validateMe();"/><td></td></tr>
            </table>
            <div id="responds"></div>
        </form>
    </body>
</html>

我需要使用带有 php 和 ajax 的 RESTful Web 服务将这些数据插入到我的 MySql 数据库中。

我该如何实现这一点。谁能帮我做这件事。

4

1 回答 1

0

First, I suggest you to use the jQuery Javascript framework. With it, it made dead simple to make AJAX requests and getting the input values (without worrying of the web browser, etc).

Second, I don't see any RESTful web service here. It's a simple POST form.

So please, details your question :)

于 2012-09-18T09:17:54.667 回答