[jQuery]使用jQuery ajax post 调用 .Net MVC Controller

说明如何透过jQuery的ajax post来调用后端Controller


例如我们想达成以下功能

1. 输入姓名

2. 按下按钮

3. ajax post 调用后端Controller返回数据

4. 前端页面接收数据后显示

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



原文:大专栏  [jQuery]使用jQuery ajax post 调用 .Net MVC Controller


猜你喜欢

转载自www.cnblogs.com/petewell/p/11516604.html
今日推荐