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;



    ?>

  • 相关阅读:
    C#通过文件头判断图像格式(摘录)
    devenv.exe 应用程序错误
    LINQ TO SQL中的selectMany(转)
    DragDrop registration did not succeed. (摘录)
    API各函数作用简介(转)
    Linq递归用法(摘录)
    (转)逐步为对象集合构建一个通用的按指定属性排序的方法
    何止 Linq 的 Distinct 不给力(转)
    关于sql日志文件
    DES算法的C#实现
  • 原文地址:https://www.cnblogs.com/jiangwenli/p/4860301.html
Copyright © 2011-2022 走看看