as follows:
1: Non-Ajax
Front desk:
Corresponding background:
2: JQuery Ajax
Before introducing the use of JQuery to submit forms, we need to first reference jquery.form.js, which comes from http://www.malsup.com/jquery/form/. At this point, the JS files we need to reference are:
Functional requirements: Ajax submits the form, processes the request in the controller HelloWorld4Controller, and returns some data. The data format is JSON.
First, we assume that the returned JSON entity is:
The above code tells us that it is very convenient if we want to return other entities.
Frontend part code:
If the button does not use submit, but button, then the code in the above picture should be changed to the following form:
Source code download: MvcApplication5.zip