标签:post info web ati route rip asp.net .ajax ret
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Http; using WebApplication1.Models; namespace WebApplication1.Controllers { [RoutePrefix("api/Test")] public class TestController : ApiController { // GET: Test [Route("Index")] [HttpPost] public UserInfo Index(UserInfo userInfo) { return userInfo; } } }
<div class="jumbotron"> <h1>ASP.NET</h1> <script src="~/Scripts/jquery-1.10.2.js"></script> <script type="text/javascript"> var userInfo = {"UserName":"chm","Age":3}; $(function () { $("#btnTest").click(function () { $.ajax({ type: "POST", url: "/api/Test/Index", data:userInfo, success: function (data) { alert(data.UserName+data.Age); } }); }); }); </script> </div> <div > <input type="button" id="btnTest" value="test"/> </div>
标签:post info web ati route rip asp.net .ajax ret
原文地址:http://www.cnblogs.com/caohuimingfa/p/6431999.html