Once learned Ajax, not particularly familiar with the use of the opportunity to learn MVC, a good experience of a, very grateful to the "MVC Development Practice" This book, looked at two or three times, just calculate the entire operation of the MVC mechanism has a certain understanding, the following to share our frequently used in the development of the asynchronous form of the operation.
DEMO
1.VIEW
<span style= "FONT-SIZE:18PX;" >@{Layout = null;} <! DOCTYPE html>
2.Controller
<span style= "FONT-SIZE:18PX;" >//<summary>//Controller// </summary> public class Homecontroller:controller { Public ActionResult Index () { return View (); } <summary>//// asynchronous request method, return the content object of the time///</summary>// <returns></returns > Public actionresult GetDate () { System.Threading.Thread.Sleep ($); Return Content (DateTime.Now.ToString ()); } } </span>
2. The results show
3. Code Analysis
1. Asynchronous connections
@Ajax. ActionLink () method, several commonly used parameters have been shown in the demo, and have added detailed comments, mainly used to implement asynchronous connection operations. And you can manipulate the content that is returned.
2. Asynchronous forms
Ajax.beginform () method, I have to say, in MVC will often use this method, as the same, the demo has detailed comments, no longer say. For example, when we are doing a login function, we can take an asynchronous form. By submitting a form to the background, and then returning the results of the login in reality to view, it is very convenient.
An Ajax asynchronous form of MVC