gpt4 book ai didi

javascript - UploadCare 在关闭对话框时不显示警报

转载 作者:行者123 更新时间:2023-11-29 10:41:48 25 4
gpt4 key购买 nike

当 UploadCare 对话框关闭时,我希望显示警报,但它没有。为什么不呢?''

$('#uc_open').on('click', function() {
uploadcare.openDialog(null, {
imagesOnly: true
}).done(function(file) {
file.done(function(fileInfo) {
//
}).fail(function(error, fileInfo) {
alert(error);
});
});
return false;
});

最佳答案

您已经订阅了openDialog().done()。当用户选择一个文件并单击对话框中的“完成”时,将调用此回调。在此回调中,您收到 file 对象并订阅 file.fail() 回调。当由于网络错误或验证器不满足而导致文件上传失败时,将调用此回调。

如果你想订阅当用户没有选择文件就关闭对话框时的回调(点击右上角的×,或者按ESC),你应该订阅openDialog().fail() :

$('#uc_open').on('click', function() {
// Open the dialog on button cick
uploadcare.openDialog(null, {
imagesOnly: true
}).done(function(file) {
// User has just clicked "Done" in Uploadcare dialog
file.done(function(fileInfo) {
// File uploading succeeded
});
}).fail(function(error, fileInfo) {
// User just has closed the dialog by pressing ESC or clicking on "×"
alert(error);
});
return false;
});

关于javascript - UploadCare 在关闭对话框时不显示警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27613409/

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