tags:

views:

103

answers:

1

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 GetWarningList(string id)
        {
            List<WarningList> OldBck = new List<WarningList>();

            return this.Json(OldBck);

        }
+3  A: 

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);
Nicholas Murray
thank you JsonRequestBehavior.AllowGet working good
Sefer KILIÇ