gpt4 book ai didi

javascript - 降落区 : Uncaught Error: No URL provided

转载 作者:行者123 更新时间:2023-12-01 05:27:01 35 4
gpt4 key购买 nike

我有以下表格:

<form class="block-center" id="pdfForm" method="POST" action="form_threatment.php" enctype="multipart/form-data" style="margin-top: 30px;">    
<div class="form-group push-50-t col-md-12">
<div class="col-md-12">
<div class="form-material form-material-primary">
<div class="dropzone dropzone-previews" id="pdfFile">
</div>
</div>
</div>
</div>
</div>

<div class="form-group push-50-t col-md-6">
<div class="col-md-12">
<div class="form-material form-material-primary">
<input class="form-control" name="first_name" type="text" id="first_name" />
<label for="first_name"><span class="asterix">*</span> Prénom : </label>
</div>
</div>
</div>

我包含 dropzone.js 库,如下所示:

<script src="assets/js/dropzone.js"></script>

还有我自己的拖放区 myDropzone.js :

<script src="assets/js/myDropzone.js"></script>

myDropzone.js 文件中,我这样配置了 div#pdfFile:

Dropzone.autoDiscover = false;

$(document).ready(function() {

Dropzone.options.pdfFile = {
// url does not has to be written if we have wrote action in the form tag but i have mentioned here just for convenience sake
url: 'form_threatment.php',
acceptedFiles: '.pdf',
maxFilesize: 20,
addRemoveLinks: true,
autoProcessQueue: false, // this is important as you dont want form to be submitted unless you have clicked the submit button
uploadMultiple: false,
autoDiscover: false,
paramName: 'pdf', // this is optional Like this one will get accessed in php by writing $_FILE['pic'] // if you dont specify it then by default it taked 'file' as paramName eg: $_FILE['file']
previewsContainer: '#pdfFile', // we specify on which div id we must show the files
clickable: false, // this tells that the dropzone will not be clickable . we have to do it because v dont want the whole form to be clickable

accept: function(file, done) {
console.log("uploaded");
done();
},
error: function(file, msg){
alert(msg);
},
init: function() {
var myDropzone = this;

// #submit-all it the id of the submit button
$("#submit-all").on("click", function(e) {
var files = $('#pdfFile').get(0).dropzone.getAcceptedFiles();
console.log(myDropzone);
console.log(files);
//e.preventDefault();
//e.stopPropagation();
myDropzone.processQueue(); // this will submit your form to the specified action path
// after this, your whole form will get submitted with all the inputs + your files and the php code will remain as usual
//REMEMBER you DON'T have to call ajax or anything by yourself, dropzone will take care of that

});
}
};
Dropzone.options.pdfFile.init();
});

加载页面时出现错误:

Uncaught Error: No URL provided.

之前,我修改了 dropzone.js 文件来设置 Dropzone 选项,但我重置了 dropzone.js 库文件并决定在 myDropzone.js 中设置选项强> 文件。

当在 dropzone.js 文件中设置选项时,我没有错误,但在重置这些选项并在 myDropzone.js 中设置它们后,我遇到了错误这个错误,这让我相信 myDropzone.js 中的选项未初始化

事实是,当我单击#submit-all 按钮时,init() 函数可以正常工作。

请问有什么办法可以解决这个问题吗?

<小时/>

好的,我解决了:

Uncaught Error: No URL provided.

删除它。

现在,当我提交时,出现以下错误:

Uncaught TypeError: myDropzone.processQueue is not a function

在 init() 函数中。

编辑:

我通过删除 processQueue 函数并阻止上传页面的“验证”按钮解决了上一个错误,直到 PDF 尚未成功上传。我知道这是一个丑陋的黑客,但我没有找到其他方法来做到这一点。

最佳答案

不要将 dropzone 代码放入 jquery $(document).ready(function(){ });

关于javascript - 降落区 : Uncaught Error: No URL provided,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39181295/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com