weixin_33697898 2018-01-23 18:00 采纳率: 0%
浏览 27

Ajax Get plus Jquery附加

I have a little function to get an array asynchronus. I get the response and this all works, the only thing wich dont, is the appending from the child. I dont know if this works like this, i tried, but it didnt worked.

function getFiles(e, uname){
    $.get({
        url: `http://myurl/files/${uname}?dir=${e.id}`,
        success(response){
          for(let i = 0; i < response.length; i++){
            $(`#${e.id}`).append('<div class="collapsible-body"><a href="/files/'+uname+'/download/'+response[i]+'">'+response[i]+'</a></div>');
             // $(`#${e.id}`).append("HELLO");
          }
        },
        error(err){
          console.log(err);
        }
    })
}

It would be really nice if anyone has an answer. I am a bit new at javascript :D Thanks. If it is to unclear, please comment. HTML/EJS:

  <div class="row">
    <ul class="collapsible" data-collapsible="accordion">
        <% for(let i = 0; i < directories.length; i++){ %>
      <li id="<%= directories[i] %>" onclick="getFiles(this,'<%= user.username %>')">
        <div class="right" style="margin: 15px 10px 0 0"><a href="<%= user.username%>/bills/<%= directories[i] %>">Rechnung</a></div>
          <div class="collapsible-header"><i class="material-icons">card_travel</i><%= directories[i] %></div>

      </li>
        <% } %>
    </ul>
  </div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度