This article mainly describes jquery using Ajaxsubmit () Submission Form example, using the third-party plug-in jquery.form implementation, the need for friends can refer to the next,
The Ajaxsubmit (obj) method is a plug-in jquery.form.js inside the jquery method, so using this method requires first introducing this plugin. As shown below:
<script src= "Http://code.jquery.com/jquery-1.11.0.min.js" ></script>
<script src= "Http://malsup.github.io/jquery.form.js" ></script>
So, how do you submit data through Ajaxsubmit (obj)? First we need a form:
Xhtml
<form>
Title: <input type= "text" name= "title"/><br/>
Content: <textarea name= "Content" ><textarea/><br/>
<button> Submit </button>
</form>
The above is a form that needs to submit content, usually, we submit directly through the form, after the submission of the current page to the form of the action point to the page. However, many times we do not want to submit the form after the page jumps, then we can use Ajaxsubmit (obj) to submit the data. Use the following method:
$ (' button '). On (' click ', function () {
$ (' form '). On (' Submit ', function () {
var title = $ (' inpur[name=title] '). Val (),
Content = $ (' textarea '). Val ();
$ (this). Ajaxsubmit ({
Type: ' Post ',//submission method Get/post
URL: ' Your URL ',//URL to submit
Data: {
' title ': Title,
' Content ': Content
},
Success:function (data) {//Database----typically JSON data--that is returned after the commit is saved
Data can be processed here
Alert (' Submit success! ‘);
}
$ (this). Resetform (); Reset form after submission
});
return false; Prevent forms from automatically submitting events
});
});
Transferred from: http://www.jb51.net/article/48728.htm
Method of form Ajax submission with file tag files upload: jquery's Ajaxsubmit ()