My Dropzone is limited to 2 Files ( maxFiles: 2). If the user drags a new File into the Dropzone, the maxfileexceeds event shows an error.
myDropzone.on("maxfilesexceeded", function(file){
alert("no more files accepted");
myDropzone.removeFile(file);
})
But: If I add the "error event"..
myDropzone.on("error", function(file, errormessage, response){
alert(response.message);
})
to get a response if something fails, Dropzone alerts an "undefined". The params on the error event should be correct.. Qoute(DropzoneJS homepage):
error: An error occured. Receives the errorMessage as second parameter and if the error was due to the XMLHttpRequest the xhr object as third.
So the first param is the file, second an errormessage (according to the author) and the 3rd param is a error which es from the server.
The error response on the server looks like this:
$response = array('status' => 'error', 'message' => 'unknown error occured');
header('HTTP/1.1 500 Internal Server Error');
header('Content-type: application/json');
$response["message"] = $message;
exit (json_encode($response));
so why does Dropzone give me an "undefined" ?
My Dropzone is limited to 2 Files ( maxFiles: 2). If the user drags a new File into the Dropzone, the maxfileexceeds event shows an error.
myDropzone.on("maxfilesexceeded", function(file){
alert("no more files accepted");
myDropzone.removeFile(file);
})
But: If I add the "error event"..
myDropzone.on("error", function(file, errormessage, response){
alert(response.message);
})
to get a response if something fails, Dropzone alerts an "undefined". The params on the error event should be correct.. Qoute(DropzoneJS homepage):
error: An error occured. Receives the errorMessage as second parameter and if the error was due to the XMLHttpRequest the xhr object as third.
So the first param is the file, second an errormessage (according to the author) and the 3rd param is a error which es from the server.
The error response on the server looks like this:
$response = array('status' => 'error', 'message' => 'unknown error occured');
header('HTTP/1.1 500 Internal Server Error');
header('Content-type: application/json');
$response["message"] = $message;
exit (json_encode($response));
so why does Dropzone give me an "undefined" ?
Share Improve this question asked Jul 14, 2016 at 15:49 shiroxxsshiroxxs 511 silver badge7 bronze badges 01 Answer
Reset to default 7The third parameter is an XHR
object not the response. Please try this:
myDropzone.on("error", function(file, errormessage, xhr){
if(xhr) {
var response = JSON.parse(xhr.responseText);
alert(response.message);
}
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744293559a4567149.html
评论列表(0条)