• jQuery.form 中的 ajaxForm() 和 ajaxSubmit()


    官方例子  http://malsup.com/jquery/form/#ajaxForm
    官方API   http://malsup.com/jquery/form/#api
    中文API   http://www.aqee.net/docs/jquery.form.plugin/jquery.form.plugin.html#api

    参考 http://www.cnblogs.com/qiantuwuliang/archive/2009/09/14/1566604.html#commentform

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
      <title>My Jquery</title>
      <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
      <script type="text/javascript" src="http://malsup.github.io/min/jquery.form.min.js"></script>
      <script type="text/javascript">
       // wait for the DOM to be loaded
            $(document).ready(function() {
              //该方法是对表单做一些操作 使得原本很普通的form具备了无刷新提交的功能 这样普通的表单在点击submit的时候就可以无刷新提交  限制就是必须点击submit按钮才能提交
              $('#myForm').ajaxForm();
              var options = { 
                target: '#output2',   // target element(s) to be updated with server response 
              };
              
    
              //当点击提价按钮的时候  调用ajaxSubmit() 提交  同时屏蔽原有的form的页面跳转
              /*$('#myForm2').submit(function() {    
                // submit the form    
                $(this).ajaxSubmit();    
                // return false to prevent normal browser submit and page navigation    
                return false;
              });*/
              $('#btn2').click(function(event) {
                $('#myForm2').ajaxSubmit();//使用ajaxSubmit的好处就是任何时候调用本方法 就可以提交了  无需点击submit按钮
              });
    
            });
            // attach handler to form's submit event
    
        </script>
    
    </head>
    <body>
      <form id="myForm" action="index.php" method="post">
        Name:
        <input type="text" name="name" />
        Comment:
        <textarea name="comment"></textarea>
        <input type="submit" value="Submit Comment" />
      </form>
      <button id="btn1">btn1</button>
      <div id="output2"></div>
      <form id="myForm2" action="index.php" method="post">
        Name:
        <input type="text" name="name" />
        Comment:
        <textarea name="comment"></textarea>
      </form>
      <button id="btn2">btn2</button>
    </body>
    </html>
  • 相关阅读:
    Linux——配置secureCRT远程连接图形化显示
    Oracle——insert ino,insert all into,insert first into
    Mysql——case函数
    Mysql——语句执行顺序
    Mysql——实现按字段部分升序,部分降序的方法
    无线网ping虚拟机
    http协议
    eclipse——32位64位Eclipse和jdk对应关系
    2019-07-24_windows系统一些常用的dos命令
    2019-07-23_zabbix监控安装视频教程
  • 原文地址:https://www.cnblogs.com/cart55free99/p/3507341.html
Copyright © 2020-2023  润新知