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);
精彩评论