Use jquery to reuse form forms and submit them asynchronously to another action

Source: Internet
Author: User
Tags blank page

in the development of the page, sometimes to reuse the form of data, and asynchronous requests submitted to other links, this time can use jquery to modify the form's action value (remember to change back after use), and call the Submit method, Of course, the link action or controller method in the background must return a value of type void, otherwise a page jump will occur, return NULL to display a blank page, cannot implement an asynchronous call. Alternatively, you can use another way to commit, serialize the form, and then submit it with jquery Ajax, but process the returned information. Directly on the code: (1) jquery Changes the form property
$ (". Exportbrandsort"). On (' click ', Function () {         var url = contextpath+ "/brand/exportbrandsort";     $ (' #searchform '). attr (' action ', URL);     $ (' #searchform '). Submit ();     Restore Action value     url = contextpath+ "/brand/getbrand";     $ (' #searchform '). attr (' action ', URL);       });

(2) Ajax submission method
$ (". Exportbrandsort"). On (' click ', Function () {         var url = contextpath+ "/brand/exportbrandsort";     var data= $ (' #searchform '). Serialize ();        $.ajax ({      type: ' GET ',      url:url,      data:data,      success:function (Retjson) {          }    });    });


Use jquery to reuse form forms and submit them asynchronously to another action

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.