我试图编写一个脚本来检查dropzone上是否有任何图像丢失。 我正在使用Twitter bootstrap。
在提交时运行的ajax脚本是:
$.ajax({
type: method,
action: action,
data: formdata,
processData: false,
contentType: false,
dataType: 'json',
beforeSend: function(xhr) {
if (myDropzone.getQueuedFiles().length == 0) {
// I've managed to get the values of the number of images dropped.
// I want to inform the user that they've not added any images,
// They can continue to submit without adding images if they click on continue on the modal
// Or click cancel and drop some images.
}
},
success: function(data) {
console.log(data);
},
error: function(data) {
var errors = data.responseJSON;
console.log(data);
$.each(errors, function(key, value) {
$('#' + key).after('<div class="alert alert-danger">' + value + '</div>');
});
}
});
我不确定如何实现这一目标。感谢您阅读