ASP.NET MVC 中的拖放区错误消息
Dropzone error messages in ASP.NET MVC
使用ASP.NET MVC,我return一个错误,当提交的app/form缺少一些东西时,我得到一个漂亮的红色"X" 在 dropzone 文件上,但错误消息是 "[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>
这是我的解决方案
<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>
使用ASP.NET MVC,我return一个错误,当提交的app/form缺少一些东西时,我得到一个漂亮的红色"X" 在 dropzone 文件上,但错误消息是 "[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>
这是我的解决方案
<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>