簡體   English   中英

ASP.NET MVC中的Dropzone錯誤消息

[英]Dropzone error messages in ASP.NET MVC

使用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>

這是我的解決方案

<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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM