我不能为我的生活弄清楚为什么下面的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
}
});
它永远不会出现警报“我设法解析它!”
答案 0 :(得分:2)
<强>解决强>
Plupload FileUploaded事件文档建议第三个参数是响应对象。事实上并非如此!响应对象包含在 THAT 对象中,即要查看您必须执行以下操作的响应数据:
uploader.bind("FileUploaded", function (up, file, response) {
alert(response.response);
});
希望这能节省一些时间:)