【发布时间】:2018-05-31 09:28:24
【问题描述】:
这是我的控制器,我在这里返回错误
if(!empty($chckDocsDup)){
$return['error'] = 1;
return response()->json($return);
exit();
}
在我的 Dropzone 中,我使用 this.on('error', function()) 收到了这些错误,但它没有发出警报。有什么替代方案吗?
$(document).ready(function () {
var uplodURLother = '{{url(ADMIN."/uploaddocument")}}';
var metaTokenOther = $('meta[name="_token"]').attr('content');
var uploaddoctypeOther = $('#uploaddoctype_other').val();
Dropzone.options.myDropOther = {
acceptedFiles: ".pdf,.doc,.docx",
url: uplodURLother,
sending: function(file, xhr, formData) {
formData.append("_token", metaTokenOther);
formData.append("doctype", uploaddoctypeOther);
formData.append("candidateid", '{{$candidateDet['candidateid'] }}');
},
init: function() {
this.on("removedfile", function(file) {
$(".remv_"+file.doctype+"_"+file.filecnt).remove();
});
this.on('success', function(file, response) {
alert('hai');
});
this.on('error', function(file, response) {
alert('response'); //This alert is not working
});
}
};
});
【问题讨论】:
-
需要返回错误http状态码:
return new JsonResponse(['reason' => 'Some Reason'], 400); -
您能否将解决方案发布为答案
-
你使用的是什么版本的 Laravel?另外,您如何进行验证?你能展示整个控制器方法吗?
标签: php laravel dropzone.js