Blueimp文件上传:我的DELETE链接不起作用

这是我的表格(基本上传):

 Select files...   

这是我的脚本:

 $(function () { $('#fileupload').fileupload({ url: 'server/php/', dataType: 'json', add: function (e, data) { data.context = $('

').text('Uploading...').appendTo('#files'); data.submit(); }, done: function (e, data) { $.each(data.result.files, function (index, file) { $('

').html('Delete').appendTo('#files'); }); } }); });

我的上传没问题但是当我点击DELETE链接时,没有任何反应。 看来这个链接没有效果。 也许我错过了包含的东西?

任何的想法 ?

除非我遗漏了什么,否则你没有在链接上设置事件监听器。

 $('#files').on('click', 'a', function (e) { e.preventDefault(); var $link = $(this); var req = $.ajax({ dataType: 'json', url: $link.data('url'), type: 'DELETE' }); req.success(function () { $link.closet('p').remove(); }); }); 

你可能已经解决了你的问题但只是为任何新的解决方案寻求者添加我的答案。

您不需要像@rglyall那样手动发出删除请求,只需正确设置html结构,Jquery-file-upload就会自行处理。

更改

Delete

  

你需要确保以下内容存在于库中自动处理这个问题

  1. Html元素必须是“按钮”。
  2. 此按钮必须具有“删除”类。
  3. 此按钮必须具有“数据类型”。
  4. 这个按钮必须有’ade-url’。