【发布时间】:2016-07-14 15:49:18
【问题描述】:
我的 Dropzone 限制为 2 个文件 (maxFiles: 2)。如果用户将新文件拖入 Dropzone 中,maxfileexceeds 事件会显示错误。
myDropzone.on("maxfilesexceeded", function(file){
alert("no more files accepted");
myDropzone.removeFile(file);
})
但是: 如果我添加“错误事件”..
myDropzone.on("error", function(file, errormessage, response){
alert(response.message);
})
为了在出现故障时得到响应,Dropzone 会发出“未定义”警报。 错误事件的参数应该是正确的.. Qoute(DropzoneJS主页):
错误:发生错误。接收 errorMessage 作为第二个参数,如果错误是由于 XMLHttpRequest 引起的,则将 xhr 对象作为第三个参数。
所以第一个参数是文件,第二个是错误消息(根据作者),第三个参数是来自服务器的错误。
服务器上的错误响应如下:
$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));
那么为什么 Dropzone 给我一个“未定义”?
【问题讨论】:
标签: javascript php html dropzone.js