开发者

mvc2 migration issue

i migrate my mvc1 project to mvc2.

my jquery json result function does not work anymore. have any idea ?

aspx

$.getJSON('Customer/GetWarningList/0', function(jsonResult) {
                    $.each(jsonResult, function(i, val) {
                        $('#LastUpdates').prepend(jsonResult[i].Url);
                    });

                });

controller

public JsonResult GetWarningLi开发者_如何学编程st(string id)
        {
            List<WarningList> OldBck = new List<WarningList>();

            return this.Json(OldBck);

        }


There has been a change to JsonResult in MVC 2 and therefore it will no longer work with HTTP GET to avoid Json hijacking.

So you have two options

a. return your results via HTTP Post 

or 

b. the JsonRequestBehavior property to JsonRequestBehavior.AllowGet

There is an interesting article on how to modify here.

or (more elegant)

c. return Json(data, JsonRequestBehavior.AllowGet);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜