ajax 请求JSON在MVC使用注意事项:

ajax前台请求方式:

 

 

 

MVC后台返回方法:

第一种:对象转换成JSON格式再通过Response.Write(json);写入到文件流中:

string json = JsonConvert.SerializeObject(new { BetEniqures = rsp1.BetEniqures, AboveGameDrawDates = rsp1.AboveGameDrawDates, EventType = eventType });
Response.Write(json);
Response.End();

 

第二种:直接使用JSON格式直接转送:

public ActionResult JsonResult()

        {
            //自动将传入的对象序列化成json格式写入到response对象中
            return Json(new { Name = " 八戒", Age = 500 }, JsonRequestBehavior.AllowGet);
        }

 

posted on 2015-05-12 21:13  高达  阅读(169)  评论(0)    收藏  举报

导航