Plupload响应对象

时间:2013-06-06 10:14:39

标签: asp.net-mvc plupload

我不能为我的生活弄清楚为什么下面的Plupload返回的响应对象无法解析。

我从ASP.NET MVC控制器返回一个JsonResult,如下所示:

    public JsonResult Upload()
    {
        // code to process the upload
        return Json(new { success = true, data = "Some response data" });
    }

我在视图中阅读如下:

    uploader.bind("FileUploaded", function (up, file, response) {
        response = $.parseJSON(response);

        alert("I managed to parse it!");

        if (response.success) {
            // do something with the response data
        } else {
            // tell the user there was an error
        }
    });

它永远不会出现警报“我设法解析它!”

1 个答案:

答案 0 :(得分:2)

<强>解决

Plupload FileUploaded事件文档建议第三个参数是响应对象。事实上并非如此!响应对象包含在 THAT 对象中,即要查看您必须执行以下操作的响应数据:

    uploader.bind("FileUploaded", function (up, file, response) {
        alert(response.response);
    });

希望这能节省一些时间:)