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>
    
  • 相关阅读:
    一道编程面试题
    AtCoder Grand Contest 016 B
    AtCoder Regular Contest 076 D
    Codeforces Round #419 (Div. 2) B. Karen and Coffee
    2017 计蒜之道 复赛 Windows画图+百度地图导航
    Codeforces Round #418 (Div. 2) B. An express train to reveries
    棠梨煎雪
    Bits And Pieces
    Let Them Slide
    TeaTree
  • 原文地址:https://www.cnblogs.com/zhouein/p/4972507.html
Copyright © 2011-2022 走看看