json - Retuning a JsonResult -


i'm trying return text message box when error occurs , return type jsonresult.

i believe i'm returning valid type, when messagebox appears, says "undefined".

i have json set following:

string maxchars = "upload file size exceeded!"; return json(new { maxcharacters = maxchars }); 

what doing wrong?

if returning json data httpget action method, should explicitly tell json method allow sending json data request.

public actionresult yourmethod() {     string maxchars = "upload file size exceeded!";     return json(new { maxcharacters = maxchars }, jsonrequestbehavior.allowget); } 

and in client side code, should accessing maxcharacters property of response coming ajax call.

$.get("@url.action("yourmethod","yourcontrollername")",function(res){   alert(res.maxcharacters); }); 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -

r - Update two sets of radiobuttons reactively - shiny -