zoukankan      html  css  js  c++  java
  • AJAX结合form表单post提交

    <!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>
    <title>AJAX结合form表单post提交</title>
    <meta name="generator" content="editplus" />
    <meta name="author" content="" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <script type="text/javascript" 
    
    src="http://www.wmdfw.com/h_ui/jquery.js"></script>
    
    <script type="text/javascript">
    $(document).ready(function(){
      $("button").click(function(){
        $("div").text($("form").serialize());
        alert($("form").serialize());
        var data=$("form").serialize();
        $.ajax({
        url: 'x.php',
        type: 'post',
        data:data,
        dataType: 'html',
        timeout: 1000,
        error: function(){
         alert('Sorry!注册错误,请联系管理员!');
        },
        success: function(html){
         //$('#text').html(html);
         alert('注册成功!');
         window.location.href='http://www.wmdfw.com/';
        }
        });
      });
    });
    </script>
    </head>
    <body>
    <form action="">
    用户名: <input type="text" id="name" name="name" value="zhangsan" /><br />
    密  码: <input type="text" id="pwd" name="pwd" value="123456" /><br />
    性  别: <input type="text" id="sex" name="sex" value="0" /><br />
    </form>
    <button>序列化表单提交</button>
    <div></div>
    </body>
    </html>
    
  • 相关阅读:
    22 有序化模块
    21模块
    Day20 继承
    Day19 约束
    面向对象 成员
    面向对象01
    内置函数、匿名函数、递归、二分法
    生成器函数 推导式
    Unity3D 实现方块跑酷
    day30-2018-12-3-进程
  • 原文地址:https://www.cnblogs.com/zhouein/p/4972507.html
Copyright © 2011-2022 走看看