The Ajax asynchronous submission form of MVC

Source: Internet
Author: User

The first usage:

In MVC, you can still use the Ajax checksum, as in WebForm, the only difference is to change the previous URL path to the behavior of the access controller.

Front desk 

In fact, MVC has already made a better encapsulation of JSON, in terms of background code, you can return to Jsonresult, so you can dispense with your own handwriting JavaScriptSerializer class

Second usage:

The AJAX checksum has been well encapsulated in MVC and can be directly point out using the associated class library.

Ajax.beginform (...)

First, because even if Microsoft's MVC is encapsulated, it still relies on Ajax, so it needs to add the corresponding J file

<script src= "~/scripts/jquery-1.8.2.min.js" ></script>
<script src= "~/scripts/jquery.unobtrusive-ajax.min.js" ></script>

The above code implements an asynchronous commit operation, Of course, Ajax.beginform has a lot of overloads, can achieve basic all the handwriting function, but also found that the type of the Submit button is a submit type, but still is the process of asynchronous invocation, the specific reason is that the implicit JS file, the first will find the tagged form form, and then the data in the form into Not be affected by the subsequent commit button.

The Ajax asynchronous submission form of MVC

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.