MVC: How to Return a String as JSON

后端 未结 5 419
刺人心
刺人心 2020-11-27 16:58

In an effort to make a progress reporting process a little more reliable and decouple it from the request/response, I am performing the processing in a Windows Service and p

5条回答
  •  难免孤独
    2020-11-27 17:21

    Use the following code in your controller:

    return Json(new { success = string }, JsonRequestBehavior.AllowGet);
    

    and in JavaScript:

    success: function (data) {
        var response = data.success;
        ....
    }
    

提交回复
热议问题