Example of form submission in EasyUI of jquery plug-in _ jquery-js tutorial

Source: Internet
Author: User
This article mainly introduces the form submission instance in the jquery plug-in EasyUI, which has some reference value. If you are interested, refer to passing parameters to the Controller using AJax, then, call the method on the server side to change the database. Today, a new method is submitted as a form, which saves the trouble of passing parameters through AJax.

After the form is submitted, we can obtain the value in the form control, and then call the server method to change the database. The following is a specific business requirement.


1. functions to be implemented: obtain the value in the control from the form above and pass it to the background. The following is the form code.
Ii. form code

Iii. Form submission code

Function EditsubmitForm () {$ ('# editform '). form ('submit ', {url: "/BasicClass/ModifyClassInfo", onSubmit: function () {// callback function var isValid = $ (this) before the form is submitted ). form ('validate'); // verify that the values of some controls in the form are correct. For example, if (! IsValid) {} return isValid; // If verification fails, return false to terminate form submission}, success: function (data) {// callback function after the form is submitted successfully, the data parameter is the return value of the/BasicClass/ModifyClassInfo method. If (data> 0) {$. messager. show ({title: 'message message', msg: 'submitted successfully', showType: 'show', timeout: 1000, style: {right: '', bottom: ''}); $ ('# dg '). datagrid ('reload'); // reload the data on the current page $ ('# editwin '). window ('close'); // close the window} else {$. messager. alert ('prompt information', 'submission failed. Please contact the administrator! ', 'Warning ');}}});}

4. The background Controller obtains the data in the form.

// Obtain the name of the class to be added string ClassName = Request. form ["ClassName"]; // obtain the class ID Guid ClassID = new Guid (Request. params ["ClassID"]); string ClassNote = Request. form ["Note"];

At first glance, I feel much more useful than passing parameters through AJax. Because AJax requires writing all the parameter names when passing parameters, when submitting a form, by default, all the content in the form is transmitted to the system, so that we can obtain any data in the background as long as there is any data in the form. Of course, the data is bound in advance, or we have filled it out before.

The above is all the content of this article, and I hope it will help you learn jquery programming.

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.