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条回答 默认 最新

    报告相同问题?