您当前的位置:KKBlog > 学无止境 > WEB前端

MVC中返回JSONResult要特别注意的事情

前台

$.ajax({

                    type: "get",
                    cache: false,
                    url: "/xxx/xxx/",
                    success: function (retValue)
                    {
                    }

                });

当前台使用get方式请求时,后台返回JSONResult必须设置JsonRequestBehavior.AllowGet,否则前台会得不到返回值

如:

return Json(new { flag = "success", Name = "秋风雅居", Url = "http://www.198933.com"},JsonRequestBehavior.AllowGet);

 
二维码
意见反馈 二维码