HTML 的按钮绑定函数
<a class="btn btn-info single disabled" οnclick="AAA()" > <i class="fa fa-plus"></i> 功能 </a>
这边用layer弹窗显示请求回来的数据
JAVASCRIPT
var prefixfile = ctx + "xxx/xxxxxxx"; function AAA() { // 获取选中的行数据 let rows = $('#bootstrap-table').bootstrapTable('getSelections'); if (rows.length === 0) { alert('请选择一条记录'); return; } //列表行中某个参数,我这边用id let id = rows[0].id; $.ajax({ type: 'POST', //请求的接口 url: prefixfile + "/XXXXX", data: { id: id }, dataType: 'json', // 指定返回的数据类型为 JSON success: function(response) { if (response && response.rows) { let content = response.rows; console.log("1",content); let htmlContent = ''; content.forEach(function(file) { htmlContent += `<a href="${file.XXX}" target="_blank">${file.XXXX}</a><br>`; }); // 使用 layer 打开模态框 layer.open({ type: 1, // 页面层 title: '文件列表', area: ['1024px', '700px'], // 宽高 content: htmlContent // 填充模态框内容 }); } else { console.error('响应数据不包含 data 属性或数据为空'); } }, error: function(error) { console.error('请求出错:', error); } }); }