Example of jquery one-click AJAX submission

Source: Internet
Author: User


In website Background Development, form submission is the most basic and core function. In the face of its single submission form and single return form features, if integration is successful, in this case, both the development boss and the development experience in the background will be qualitatively improved.

This method is a piece of content that I have taken from the project. The ajax submission method is used. Please modify it a little.

My development environment is Symfony;

Simple description

Type: ajax submission method get post

Url: submitted address

# FROM submission form ID

$ ("# FROM"). serialize ()
[Serialize () for the core method, jquery method, predict more please learn] http://www.w3school.com.cn/jquery/ajax_serialize.asp

/**
* Ajax submission
 *
* @ Param type
* @ Param url
*/
Function ajaxSubmit (type, url)
{
JQuery. ajax ({
Type: type,
Url: url,
Data: $ ("# FROM"). serialize (),
DataType: 'json ',
Success: function (data ){
Alert (data. message );
If (data. errorCode = 0 | data. errorCode = 5 ){
Window. location. href = data. data. go_url;
            }
        }
})
};

Related Article

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.