2009-10-14 5 views

Répondre

13

Eh bien, probablement la meilleure solution est d'utiliser sérialisation JSON.

public ActionResult DoSomething(string parameter) 
    { 
     //do something with parameter 
     bool result = true; 
     return Json(new ActionInfo() 
     { 
      Success =result,  
     }); 
    } 

Le ActionInfo est juste une simple classe avec une propriété, Success.Then booléen, jquery appel ajax:

$.ajax({ 
type: "POST", 
url: "YourController/DoSomething?parameter=pValue", 
data: {}, 
dataType: "json", 
success: function(actionInfo) { 

    alert(actionInfo.Success); 

}}); 

Hope this helps.

Questions connexes