The simplest form submission method for jquery

Source: Internet
Author: User

First Step: Binding events

Common Ajax-related events are referred to as follows:

1, $ (selector). Click (function)

2, $ (selector). Change (function)

3, $ (selector). KeyUp (function)

4, $ (selector). Submit (function)

Prevents the default action of the Submit button before submitting the form, or returns false, such as:

1. Prevent the default action of the Submit button

$ ("form"). Submit (function (e) {
E.preventdefault ();

2. Return False

$ ("form"). Submit (function () {
return false;

Detailed jquery event that points out into

The second step: Serialize the form or object into a string, or you can serialize the form to an array of forms;

1. Serialize the form contents to a string
var data = $ ("form"). Serialize ();

2. Serialize a Key/value object:
var str = Jquery.param ({});

3, the form of serialization of the form of an array
var sa = $ ("form"). Serializearray ();

Step Three: Form submission

Form submissions can be parameterized in the following ways:

1, Jquery.ajax ([Settings])

2, Jquery.get (Url,data,success (RESPONSE,STATUS,XHR), DataType)

3, (Url,data,success (RESPONSE,STATUS,XHR), DataType)

4, Jquery.getjson (Url,data,success (DATA,STATUS,XHR))

5, $ (selector). Load (url,data,function (RESPONSE,STATUS,XHR))

6, Jquery.getscript (url,success (response,status))

For detailed Jquery.ajax, click to enter

The simplest form submission method for jquery

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: 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.