例如一个注册的表单,如果用JS脚本提交到后台数据库,
谁有例子 给一个 

解决方案 »

  1.   

    你说的就是异步提交的问题,XMLHttpRequest对象~~~
    IE:xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    FF:xmlHttp=new XMLHttpRequest();
    先open("get/post"url,true),再给xmlHttp的onreadystatechange属性赋值,最后send(null).
      

  2.   

    可以用JQuery AJax技术来实现
      

  3.   

     用jquery  ajax技术还是蛮好实现的!~
      

  4.   


    <script type="text/javascript">
        //button click
        function sendData() {
            if (jQuery.trim($('#username').val()) == "") {
                alert("Please type the username.");
                $('#username').focus();
                return false;
            }
            if (jQuery.trim($('#password').val()) == "") {
                alert("Please type the password.");
                $('#password').focus();
                return false;
            }
            
            //ajax post
            $.post("your url", 
                {username: jQuery.trim($('#username').val()), password: jQuery.trim($('#password').val())},
                function() {
                    $("#username").val("");
                    $("#password").val("");
                }
            );
        }
    </script>
    <ul class="list">
        <li><label for="username">User Name:</label><input id="username" name="username" type="text" required="true" tip="Please input your login name." /></li>
        <li><label for="password">Password:</label><input id="password" name="password" type="password" required="true" tip="Please input your password." /></li>
        <li><center><input id="btnSignCheck" style="width:60px" type="button" value="Login" onclick="sendData();"/></center></li>
    </ul>  $username = $f->filter($this->getRequest()->getParam('username'));
      $password = $f->filter($this->getRequest()->getParam('password'));
      //验证用户名与密码,代码略