2015-03-19 77 views
2

使用ASP.NET MVC,當提交的應用程序/表單丟失了某些內容時,我會在dropzone文件上獲得一個很好的紅色「X」,但錯誤消息是「[對象的對象]」ASP.NET MVC中的Dropzone錯誤消息

我的控制器:

 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

這裏是我的解決方案

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