how to return multiple variables with jsonresult asp.net mvc3

前端 未结 6 1139
半阙折子戏
半阙折子戏 2020-12-24 09:15

How to return multiple variables on JsonResult method

for example i want to return this two variables:

string result = \"Successed\";
string ID = \"         


        
6条回答
  •  一向
    一向 (楼主)
    2020-12-24 10:15

    You should return an object with multiple properties:

    return Json(new {
        result, 
        ID
    });
    

    The JSON serializer will convert C# anonymous types into JSON object literals.

提交回复
热议问题