Handling / Handling return of DropZone in JavaScript

1

I need to know how to handle the server return to display that the uploaded file was not saved!

The server return object:

public class JsonReturn
{
    public bool Ok { get; set; }
    public int LinhasAfetadas { get; set; }
    public string Mensagem { get; set; }
    public string Log { get; set; }
    public object Dados { get; set; }
    public int Id { get; set; }

}

Below is the DropZone call:

<script type="javascript">
        Dropzone.options.dropzoneForm = {
            dictDefaultMessage: "Arraste os recibos até aqui, ou clique para selecionar!",
            dictInvalidFileType: "ERRO: Tipo de arquivo não permitido!",
            acceptedFiles: "application/pdf",                
            success: function() { /* COMO DEVO TRATAR O RETORNO FAZENDO QUE SEJA EXIBIDO O "X" E O ERRO PERSONALIZADO ?*/},
        };
</script>
    
asked by anonymous 04.07.2016 / 16:51

1 answer

0

I found the answer in this post in English: Answer in English

success: function(file, response){
    if(response.code == 501){ // succeeded
        return file.previewElement.classList.add("dz-success"); // from source
    }else if (response.code == 403){  //  error
        // below is from the source code too
        var node, _i, _len, _ref, _results;
        var message = response.msg // modify it to your error message
        file.previewElement.classList.add("dz-error");
        _ref = file.previewElement.querySelectorAll("[data-dz-errormessage]");
        _results = [];
        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
            node = _ref[_i];
        _results.push(node.textContent = message);
        }
    return _results;
    }
}

Good to everyone!

    
22.07.2016 / 20:07