且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在JQuery中点击时调用ColdFusion方法

更新时间:2023-11-16 18:07:04

您需要添加一个ajax调用CFC:

You'll need to add an ajax call to the CFC:

$("#FileUploader").on('click', '.DeleteFileUpload', function (event) {
    event.preventDefault();
    $(this).parent('li').remove();
    $.ajax('/path/to/your.cfc?method=DeleteUpload&Filename=' + $(this).attr('href'));
});

您需要将删除链接的href更改为文件路径并使用preventDefault()禁用点击

You'd need to change the href of the delete link to the file path (as a reference) and disable the click by using preventDefault()

<a href="directory/filename2.pdf" class="DeleteFileUpload">Delete</a>

如果你不喜欢将文件路径放在href中,数据属性或从同级链接获取href。

If you don't like to put the file path in the href you could always put it in a data attribute or get the href from the sibling link.