M
M
Maxim Timofeev2015-06-21 16:36:43
JavaScript
Maxim Timofeev, 2015-06-21 16:36:43

How to get response from server in DropZoneJS?

In php:
echo "ddddd";
or tried a million more options
in dropzone:

function(file,response){
                    console.log(response);
                    }

in console:
XHR finished loading: POST "http://domen.new/backend/portraits/upload-original".dropzone.js:1482 Dropzone.uploadFilesdropzone.js:1289 
Dropzone.processFilesdropzone.js:1275 
Dropzone.processFiledropzone.js:1268 
Dropzone.processQueuedropzone.js:1151 
(anonymous function)
create:891 undefined

Where did undefined come from? I need to return the string to the dropzone. I've been digging a hole for three hours now.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2015-06-24
@webinar

figured it out myself.
Instead of:

function(file,response){
                    console.log(response);
                    }

it should have been like this:
function(file){
                    console.log(file.xhr.response);
                    }

R
Rikcon, 2015-06-21
@Rikcon

Dropzone has Event success
The file has been uploaded successfully. Gets the server response as second argument. (This event was called finished previously)

var myDropzone = new Dropzone("#my-dropzone");
  myDropzone.on("success", function(first,response) {
    /* Maybe display some more file information on your page */
  });

Here you need a response
Here is another found on stackoverflow.
stackoverflow.com/questions/19390471/dropzonejs-ho...
but be careful, version 4 of the dropzone has been pretty well rewritten.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question