$.get("@Hosts.Default.Www/api/XXXXX/Getxxx/"+@Model.UserId, function(data) { $("#totalPv").text("历史访问量:"+data[0]+"次"); $("#todayPv").text("今日访问量:"+data[1]+"次"); });
public class XXXXXController : ApiController { // GET api/pvrecords/5 [HttpGet] public int[] Getxxx(int id) { HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "www.xxx.com"); return new int[] { 123, 456}; } }
参考地址:http://www.cnblogs.com/akak123/p/3503934.html