jquery Plugin-Form form plug-in jquery.form.js

Source: Internet
Author: User

Jquery.form.js official website

The JQuery form plugin is an excellent AJAX form plug-in that allows you to upgrade HTML forms easily and without intrusion to support Ajax. The JQuery form has two core methods-Ajaxform () and Ajaxsubmit (), which gather functionality from controlling form elements to deciding how to manage the commit process. In addition, plugins include other methods: Formtoarray (), Formserialize (), Fieldserialize (), Fieldvalue (), ClearForm (), Clearfields (), and Resetform () and so on.

Through the plug-in, we can easily implement the form of asynchronous submission, and implementation of file upload, progress bar display and so on.

<script type= "Text/javascript" >$(function(){    varOptions = {        //target: ' #output ',//Put the contents returned by the server into an element with ID outputBeforesubmit:showrequest,//Pre-commit callback functionSuccess:showresponse,//Post-Commit callback functionResetform:true, DataType:' JSON '//Other available options:        //Url:url//default is the action of form, if stated, Overrides        //Type:type//default is form's method (get or post), if declared, overrides        //datatype:null//html (default), XML, script, JSON ... Accept the type returned by the server        //clearform:true//After a successful commit, clears the values of all form elements        //resetform:true//After a successful commit, resets the values of all form elements         //$.ajax options can used here too, for example:        //timeout:3000////Limit the time of the request, when the request is greater than 3 seconds, jump out of the request    }; //bind to the form ' s submit event$ (' #my_form '). Submit (function() {         $( This). Ajaxsubmit (options); return false;//Prevent form default submission    }); });//Pre-submit Callbackfunctionshowrequest (FormData, Jqform, options) {//formData: An Array object, when the form is submitted, the form plug-in automatically submits the data in an AJAX format such as: [{name:user,value:val},{name:pwd,value:pwd    //Jqform:jquery object that encapsulates the elements of the form    //Options:options Object    /*var uname = $ ("#uname"). Val (); if (uname== "") {$ ("#msg"). HTML ("Name cannot be empty!")        ");    return false;    } var = $ ("#age"). Val (); if (age== "") {$ ("#msg"). HTML ("Age cannot be empty!")        ");    return false; }*/    $("#msg"). HTML ("Committing ..."); return true; } //Post-submit Callbackfunctionshowresponse (ResponseText, StatusText) {$ ("#msg"). HTML (' Commit successful '); //for normal HTML responses, the first argument to the success callback    //Is the XMLHttpRequest object ' s ResponseText property     //if the Ajaxsubmit method was passed a Options Object with the DataType    //Property set to ' XML ' and the first argument to the success callback    //Is the XMLHttpRequest object ' s Responsexml property     //if the Ajaxsubmit method was passed a Options Object with the DataType    //Property set to ' JSON ' and the first argument to the success callback    //Is the JSON data object returned by the serverAlert (' Status: ' + StatusText + ' \n\nresponsetext: \ n ' + responsetext.msg + ' \n\nthe output div should have already been Updated with the responsetext. '); }</script>

jquery Plugin-Form form plug-in jquery.form.js

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.