2010-03-11 3 views
0

Je migre mon projet mvc1 vers mvc2.Problème de migration mvc2

ma fonction de résultat jquery json ne fonctionne plus. avoir une idée?

ASPX

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

       }); 
contrôleur

public JsonResult GetWarningList(string id) 
     { 
      List<WarningList> OldBck = new List<WarningList>(); 

      return this.Json(OldBck); 

     } 
+0

Avez-vous une exception? Que voyez-vous dans Firebug/Fiddler? Plus d'informations plz ... –

Répondre

3

Il y a eu un changement de JsonResult dans MVC 2 et donc il ne fonctionnera plus avec HTTP GET pour éviter le détournement JSON.

Alors vous avez deux options

a. return your results via HTTP Post 

or 

b. the JsonRequestBehavior property to JsonRequestBehavior.AllowGet 

Il y a un article intéressant sur la façon de modifier here.

or (more elegant) 

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

merci JsonRequestBehavior.AllowGet fonctionne bien –

Questions connexes