jquery-form/form is a Frontend project on GitHub, written primarily in JavaScript. It has 5.1k stars. jQuery Form Plugin
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX. The main methods, ajaxForm and ajaxSubmit, gather information from the form element to determine how to manage the submit process. Both of these methods support numerous options which allow you to have full control over how the data is submitted.
No special markup is needed, just a normal form. Submitting a form with AJAX doesn't get any easier than this!
Community
Want to contribute to jQuery Form? Awesome! See CONTRIBUTING for more information.
Code of Conduct
Please note that this project is released with a Contributor Code of Conduct to ensure that this project is a welcoming place for everyone to contribute to. By participating in this project you agree to abide by its terms.
Security
Please report security issues privately, not in public issues. See SECURITY.
Compatibility
Requires jQuery 1.7.2 or later. main is tested against jQuery 1.7.2, 3.7.1 and 4.0.0.
jQuery 4 needs a release newer than 4.3.0; 4.3.0 uses APIs that jQuery 4 removed.
With delegation: true on jQuery 3 and later, every form on the page is handled, not only the selected ones. (issue #353)
Not compatible with the jQuery slim builds, which leave out AJAX.
The jqXHR object is stored in element data-cache with the jqxhr key after each ajaxSubmit
call. It can be accessed like this:
var form = $('#myForm').ajaxSubmit({ /* options */ });
var xhr = form.data('jqxhr');
xhr.done(function() {
...
});
ajaxForm( options )
Prepares a form to be submitted via AJAX by adding all of the necessary event listeners. It does not submit the form. Use ajaxForm in your document's ready function to prepare existing forms for AJAX submission, or with the delegation option to handle forms not yet added to the DOM.
Use ajaxForm when you want the plugin to manage all the event binding for you.
// prepare all forms for ajax submission
$('form').ajaxForm({
target: '#myResultsDiv'
});
ajaxSubmit( options )
Immediately submits the form via AJAX. In the most common use case this is invoked in response to the user clicking a submit button on the form.
Use ajaxSubmit if you want to bind your own submit handler to the form.
// bind submit handler to form
$('form').on('submit', function(e) {
e.preventDefault(); // prevent native submit
$(this).ajaxSubmit({
target: '#myResultsDiv'
})
});
Options
Note: All standard $.ajax options can be used.
beforeSerialize
Callback function invoked before form serialization. Provides an opportunity to manipulate the form before its values are retrieved. Returning false from the callback will prevent the form from being submitted. The callback is invoked with two arguments: the jQuery wrapped form object and the options object.
Callback function invoked before form submission. Returning false from the callback will prevent the form from being submitted. The callback is invoked with three arguments: the form data in array format, the jQuery wrapped form object, and the options object.
beforeSubmit: function(arr, $form, options) {
// form data array is an array of objects with name and value properties
// [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
// return false to cancel submit
}
beforeFormUnbind
Callback function invoked before form events unbind and bind again. Provides an opportunity to manipulate the form before events will be remounted. The callback is invoked with two arguments: the jQuery wrapped form object and the options object.
beforeFormUnbind: function($form, options) {
// your callback code
}
filtering
Callback function invoked before processing fields. This provides a way to filter elements.
Boolean flag indicating whether the form should be cleared if the submit is successful
data
An object containing extra data that should be submitted along with the form.
data: { key1: 'value1', key2: 'value2' }
dataType
Expected data type of the response. One of: null, 'xml', 'script', or 'json'. The dataType option provides a means for specifying how the server response should be handled. This maps directly to jQuery's dataType method. The following values are supported:
'xml': server response is treated as XML and the 'success' callback method, if specified, will be passed the responseXML value
'json': server response will be evaluated and passed to the 'success' callback, if specified
'script': server response is evaluated in the global context
delegation
true to enable support for event delegation
requires jQuery v1.7+
Note: jQuery 3.0 removed the selector information this option relied on, so on jQuery 3 and later delegation is not limited to the selected forms; every form submit on the page is handled. See docs/research/selector-context-delegation.md.
// prepare all existing and future forms for ajax submission
$('form').ajaxForm({
delegation: true
});
error
Callback function to be invoked upon error. It is passed the following arguments:
jqXHR, object (the error response body is in responseText)
textStatus, string
errorThrown, string
$form jQuery object containing form element
forceSync
Only applicable when explicity using the iframe option or when uploading files on browsers that don't support XHR2.
Set to true to remove the short delay before posting form when uploading files. The delay is used to allow the browser to render DOM updates before performing a native form submit. This improves usability when displaying notifications to the user, such as "Please Wait..."
iframe
Boolean flag indicating whether the form should always target the server response to an iframe instead of leveraging XHR when possible.
iframeSrc
String value that should be used for the iframe's src attribute when an iframe is used.
iframeTarget
Identifies the iframe element to be used as the response target for file uploads. By default, the plugin will create a temporary iframe element to capture the response when uploading files. This option allows you to use an existing iframe if you wish. When using this option the plugin will not attempt handling the response from the server.
method
The HTTP method to use for the request (e.g. 'POST', 'GET', 'PUT').
replaceTarget
Optionally used along with the target option. Set to true if the target should be replaced or false if only the target contents should be replaced.
resetForm
Boolean flag indicating whether the form should be reset if the submit is successful
semantic
Boolean flag indicating whether data must be submitted in strict semantic order (slower). Note that the normal form serialization is done in semantic order except for input elements of type="image". You should only set the semantic option to true if your server has strict semantic requirements and your form contains an input element of type="image".
success
Callback function to be invoked after the form has been submitted. If a 'success' callback function is provided it is invoked after the response has been returned from the server. It is passed the following standard jQuery arguments:
data, formatted according to the dataType parameter or the dataFilter callback function, if specified
textStatus, string
jqXHR, object
$form jQuery object containing form element
target
Identifies the element(s) in the page to be updated with the server response. This value may be specified as a jQuery selection string, a jQuery object, or a DOM element.
type
The HTTP method to use for the request (e.g. 'POST', 'GET', 'PUT').
An alias for method option. Overridden by the method value if both are present.
uploadProgress
Callback function to be invoked with upload progress information (if supported by the browser). The callback is passed the following arguments:
event; the browser event
position (integer)
total (integer)
percentComplete (integer)
url
URL to which the form data will be submitted.
Utility Methods
formSerialize
Serializes the form into a query string. This method will return a string in the format: name1=value1&name2=value2
var queryString = $('#myFormId').formSerialize();
fieldSerialize
Serializes field elements into a query string. This is handy when you need to serialize only part of a form. This method will return a string in the format: name1=value1&name2=value2
var queryString = $('#myFormId .specialFields').fieldSerialize();
fieldValue
Returns the value(s) of the element(s) in the matched set in an array. This method always returns an array. If no valid value can be determined the array will be empty, otherwise it will contain one or more values.
resetForm
Resets the form to its original state by invoking the form element's native DOM method.
clearForm
Clears the form elements. This method empties all of the text inputs, password inputs and textarea elements, clears the selection in any select elements, and unchecks all radio and checkbox inputs. It does not clear hidden field values.
clearFields
Clears selected field elements. This is handy when you need to clear only a part of the form.
File Uploads
The Form Plugin supports the use of XMLHttpRequest Level 2 and FormData objects on browsers that support these features. As of today (March 2012) that includes Chrome, Safari, and Firefox. On these browsers (and future Opera and IE10) files uploads will occur seamlessly through the XHR object and progress updates are available as the upload proceeds. For older browsers, a fallback technology is used which involves iframes. More Info
Contributors
This project has transferred from github.com/malsup/form, courtesy of Mike Alsup.
See CONTRIBUTORS for details.
License
This project is dual-licensed under the LGPLv2.1 (or later) or MIT licenses:
GNU Lesser General Public License v2.1
MIT
Additional documentation and examples for version 3.51- at: http://malsup.com/jquery/form/
How does jquery-form/form compare to other Frontend projects?
jquery-form/form is tracked by TopGit in the Frontend category, with 5.1k GitHub stars and written in JavaScript. Browse the Frontend topic page on TopGit to compare it against similar projects by stars and activity.
Is jquery-form/form open source?
Yes — jquery-form/form ships under the LGPL-2.1 license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/jquery-form/form.
What else is in the Frontend space?
jquery-form/form is tracked by TopGit under the Frontend category, alongside 11 GitHub-tagged topics. Trending and Topics pages list peer repositories of comparable stars and language.
What is jquery-form/form?
jquery-form/form (jquery-form/form) is a JavaScript project on GitHub. From the project's own README: jQuery Form Plugin
Where do I read more about jquery-form/form?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/jquery-form/form is the definitive source.
Why is jquery-form/form categorized under Frontend?
TopGit places jquery-form/form in the Frontend category based on its GitHub topics and description (tagged: "ajax", "ajax-form", "form"). Categories are assigned from real repository metadata, not editorial guesswork.
Read full README in the tab above.
Still deciding about form?
One click hands the question to an AI along with this page — see what it says about form.