[JQuery] using jQuery ajax post to call .Net MVC Controller

It explains how to invoke back-end Controller via the ajax post jQuery


For example, we want to achieve the following functions

1. Enter the name

2. Press the button

3. ajax post call to return data back-end Controller

4. After receiving the front page display data

Controller

using System.Web.Mvc;

namespace MySample.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Sample()
        {
            return View();
        }

        [HttpPost]
        public string Sample(string myName)
        {
            return "您好~ " + myName;
        }
    }
}

View

@{
    ViewBag.Title = "Hello World!";
}

@ViewBag.Title



Original: Large column  [jQuery] using jQuery ajax post to call .Net MVC Controller


Guess you like

Origin www.cnblogs.com/petewell/p/11516604.html