[英]Dropzone error messages in ASP.NET MVC
Using ASP.NET MVC, I return an error, when the submitted app/form is missing something, I get a nice red "X" on the dropzone file, but the error message is "[object Object]" : 使用ASP.NET MVC,我返回一个错误,当提交的应用程序/表单缺少某些东西时,我在dropzone文件上得到一个漂亮的红色“X” ,但错误消息是“[object Object]” :
My Controller: 我的控制器:
if (some error)
{
Response.ClearHeaders();
Response.ClearContent();
Response.StatusCode = 500;
Response.StatusDescription = "Internal Error";
return Json(new { Message = "Missing Something", JsonRequestBehavior.AllowGet });
}
My Javascript: 我的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>
Here's my solution 这是我的解决方案
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.