zoukankan      html  css  js  c++  java
  • jquery通过submit()和serialize()提交表单

    <script type="text/javascript">
        $(function() {
            $('#form1').submit(function() { //当提交表单时,会发生 submit 事件。
                //此处可做表单验证
                //... ...
    			
                var postData = $("#form1").serialize();//序列化表单,后台可正常通过post方法获取数据
                $.ajax({
                    type: "POST",
                    url: "/member/member/post_member",
                    data: postData,
                    success: function(msg) {
                        if (msg == 0) {
                            alert('操作成功');
                            window.location.href = '/member/member';
                        } else {
                            alert(msg);
                        }
                    }
                });
            });
        });
    </script>
    <div>
        <form id="form1" onsubmit="return false;">  //注意:此处必须阻止表单提交
    	    <!--表单内容部分-->
            <input type="reset" value="重置" />
            <input type="submit" value="提交" />
        </form>
    </div>

    <html>
        
        <head>
            <script type="text/javascript" src="jquery.min.js"></script>
            <script type="text/javascript">
                $(document).ready(function() {
                    $("form").submit(function(e) {
                        //e.preventDefault();   //阻止表单提交
                        alert("Submit prevented");
                    });
                });
            </script>
        </head>
        
        <body>
            <form name="input" action="./b.php" method="get">
                First name:
                <input type="text" name="FirstName" value="Mickey" size="20"><br />
                Last name:
                <input type="text" name="LastName" value="Mouse" size="20"><br />
                <input type="submit" value="Submit">
            </form>
        </body>
    
    </html>
    



  • 相关阅读:
    docker 存储扩容和存放路径修改
    gitlab+jenkins+webhook 代码发布
    jenkins 流水线(pipline)
    kafka单机部署
    nload命令
    jumpserver部署维护
    mysql sleep连接过多的问题解决
    监控zabbix-server本身
    DevOps方案探究
    ceph 存储
  • 原文地址:https://www.cnblogs.com/moqiang02/p/4061174.html
Copyright © 2011-2022 走看看