如何更改URL dropzone?动态URL与Ajax成功 [英] How to change url dropzone? URL dynamically with ajax success
问题描述
我读了这篇文章: https://github.com/enyo/dropzone/ wiki / Set-URL-dynamically ,但是我没有成功... :(
我有1个表格...
I read this: https://github.com/enyo/dropzone/wiki/Set-URL-dynamically but i dont got success... :( I have 1 form...
然后我发送
ajax返回用户的新ID,这时我想更改de url dropzone来设置新用户ID的路径。
The ajax returns the new id of user. in this moment i want to change de url dropzone for to set path to id of the new user.
$.ajax({
type: "POST",
url: "class/inserir.php?funcao=teste",
data: formdata,
dataType: "json",
success: function(json){
if(json.sucesso=="sim"){
alert("Wait! Sending Pictures.");
this.options.url = "class/upload_img.php?"+json.id;
myDropzone.processQueue();
}else{
location.href="home.php?ir=cad_animal&cad=nao&erro="+json.erro;
}
}
});
var myDropzone = new Dropzone("#imagens", {
url: "class/upload_imgteste.php",
paramName: "file", // The name that will be used to transfer the file
maxFilesize: 1, // MB
addRemoveLinks : true,
dictResponseError: "Não foi possível enviar o arquivo!",
autoProcessQueue: false,
thumbnailWidth: 138,
thumbnailHeight: 120,
});
对不起,我的英语不好!
sorry for my bad english!
谢谢大家。
推荐答案
您可以在dropzone的处理事件侦听器上添加一个函数。
You may add a function on dropzone's "processing" event listener.
Dropzone.options.myDropzone = {
init: function() {
this.on("processing", function(file) {
this.options.url = "/some-other-url";
});
}
};
这是我获取代码的链接,它对我有用: https://github.com/enyo/dropzone/wiki/Set-URL-dynamically
Here is the link where I got the code and it works for me: https://github.com/enyo/dropzone/wiki/Set-URL-dynamically
这篇关于如何更改URL dropzone?动态URL与Ajax成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!