zoukankan      html  css  js  c++  java
  • 实现form表单提交到服务器,并且在将表单内容返回到该页面

    transport.php

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>向另一个页面传输数据</title>
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.min.js"></script>

    </head>

    <body>

    <script type="text/javascript">
    function test(){
        $.ajax({
            type:'POST',
            url:'tra.php',
            data : $.param({
                    user : $('form input[name=user]').val(),
                    age : $('form input[name=age]').val(),
                    sex : $('form input[name=sex]').val()
                    }),
        
            success:function(response){
                
                
                document.write(response);
                },

            })
        
        
        
        
        
        
    };







    </script>

    <form >
    姓名:<input type="text" name="user" /><br />
    年龄:<input type="text" name="age" /></br>
    性别:<input type="radio" name="sex" value="男" />男
    <input type="radio" name="sex" / value="女">女<br />


    <input type="button" value="提交" onclick="test()" />
    <input type="reset" value="重置" />


    </form>

    <div id="box" ></div>
    </body>
    </html>

    tra.php

    <?php
    $_user=$_POST['user'];
    $_age=$_POST['age'];
    $_sex=$_POST['sex'];
    echo $_user.' - '.$_age.' - '.$_sex;



    ?>

  • 相关阅读:
    传球接力
    业务办理
    P2077 红绿灯
    【UR #4】元旦激光炮
    P1939 【模板】矩阵加速(数列)
    #82. 【UR #7】水题生成器
    Visible Trees HDU
    创始人的领导力和合伙人选择
    面向对象笔试题练习一
    MicroPython+北斗+GPS+GPRS:TPYBoardv702短信功能使用说明
  • 原文地址:https://www.cnblogs.com/jiangwenli/p/4860301.html
Copyright © 2011-2022 走看看