ASP .NET 返回Json操作结果

返回string

var A="...";
var B="...";
$.ajax({
        type: "POST",
        url: "/Controller/Action",
        data: { "A": A,"B": B},
        success: function (result) {
                layer.alert(result, '操作结果');
        }
});
public ActionResult Action(string A,string B)
{
    ABManager manager =new ABManager();
    string result =manager.DoSomething(A, B);
    return Json(result, JsonRequestBehavior.AllowGet);
}

返回匿名对象

public ActionResult ReturnObjectFromCAjax(string A,string B)
{
    return Json(new
    {
        A = A + "_ok",
        B = B + "_ok",
        Success=true
    });
}

你可能感兴趣的:(ASP .NET 返回Json操作结果)