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;



    ?>

  • 相关阅读:
    软件安装
    ARIMA
    解决数据分析中的小知识点及问题
    Django详解之路由系统、中间件
    hdoj 1018
    程序员编程技术迅速提高终极攻略 (转自csdn)
    chapter 5:一个简单的规律问题。
    chapter 4:贪心
    7种qsort排序方法
    chapter 2:hdoj 1031(结构体的使用)
  • 原文地址:https://www.cnblogs.com/jiangwenli/p/4860301.html
Copyright © 2011-2022 走看看