使用ASP.NET MVC,我返回一个错误,当提交的应用程序/表单缺少某些内容时,我在dropzone文件上得到一个漂亮的红色" X" ,但是错误消息是" [object Object]" :
我的控制器:
if (some error)
{
Response.ClearHeaders();
Response.ClearContent();
Response.StatusCode = 500;
Response.StatusDescription = "Internal Error";
return Json(new { Message = "Missing Something", JsonRequestBehavior.AllowGet });
}
我的Javascript:
<script>
//File Upload response from the server
Dropzone.options.dropzoneForm = {
maxFilesize: 20,
init: function() {
this.on("complete", function(data) {
// ??????? var res = data.xhr.responseText ;
});
}
};
</script>
答案 0 :(得分:0)
这是我的解决方案
<script>
//File Upload response from the server
Dropzone.options.dropzoneForm = {
maxFilesize: 20,
init: function() {
this.on("error", function(data, errorMessage, xhr) {
$(".alertError").show();
$(".alertSuccess").hide();
$(".errMessage").text(errorMessage.Message);
});
this.on("processing", function(data) {
$(".alertError").hide();
$(".alertSuccess").hide();
});
this.on("success", function (data) {
$(".alertError").hide();
$(".alertSuccess").show();
});
}
};
</script>