jquery form ajax插件

一个好东东。

官方链接  http://malsup.com/jquery/form/

Overview

        jQuery Form Plugin 让你方便的使用ajax更新你的程序 . 主要方法: ajaxForm 和 ajaxSubmit, 同时提供很多属性方便你选择
         

Quick Start Guide

        添加一个简单的form
       

<form id="myForm" action="comment.php" method="post"> 
    Name: <input type="text" name="name" /> 
    Comment: <textarea name="comment"></textarea> 
    <input type="submit" value="Submit Comment" /> 
</form>

         

添加form需要的插件js,然后在表单启动同时执行js

       

<head> 
    <script type="text/javascript" src="path/to/jquery.js"></script> 
    <script type="text/javascript" src="path/to/form.js"></script> 

    <script type="text/javascript"> 
        // wait for the DOM to be loaded 
        $(document).ready(function() { 
            // bind 'myForm' and provide a simple callback function 
            $('#myForm').ajaxForm(function() { 
                alert("Thank you for your comment!"); 
            }); 
        }); 
    </script> 
</head>

     That’s it! 当表单提交时候会自动把text框里面的信息提交到 comment.php.  如果服务器返回成功信息,就会弹出”Thank you”信息窗口



发表评论

您的电子邮箱地址不会被公开。

78 − 73 =