But the recommended solution is to test for the 'X-Requested-With' request header.If the value of that header is 'XMLHttp Request' then you know that the form was posted via ajax.
File input elements are automatically detected and processed for you.Submitting a form with AJAX doesn't get any easier than this!Returns the value(s) of the element(s) in the matched set in an array.By default, the plugin will create a temporary iframe element to capture the response when uploading files.This options allows you to use an existing iframe if you wish.This is fine if the response type is HTML or XML, but doesn't work as well if the response type is script or JSON, both of which often contain characters that need to be repesented using entity references when found in HTML markup.
To account for the challenges of script and JSON responses when using the iframe mode, the Form Plugin allows these responses to be embedded in a element and it is recommended that you do so for these response types when used in conjuction with file uploads and older browsers.
If the 'before Submit' callback returns false then the form will not be submitted.
The 'before Submit' callback is invoked with three arguments: the form data in array format, the j Query object for the form, and the Options Object passed into ajax Form/ajax Submit. Set to true to remove short delay before posting form when uploading files (or using the iframe option).
Browsers that support the XMLHttp Request Level 2 will be able to upload files seamlessly and even get progress updates as the upload proceeds.
For older browsers, a fallback technology is used which involves iframes since it is not possible to upload files using the level 1 implmenentation of the XMLHttp Request object.
The delay is used to allow the browser to render DOM updates prior to performing a native form submit.