Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. function getowners(){
  2.  
  3. $.ajax({
  4. type: 'GET',
  5. url: '/get-owners',
  6. dataType: 'json',
  7. success: (data)=>{
  8. alert(data);
  9. $.each(data,(index,item) => {
  10.  
  11. const fila = $('<tr></tr>'); // Creamos la fila
  12.  
  13. const img = $('<td></td>').append($('<img class="image">'));
  14.  
  15. const name = $('<td></td>').addClass('name');
  16.  
  17. const action = $('<td></td>').addClass('action');
  18.  
  19. fila.append(img).append(name).append(action); // Preparamos la fila
  20.  
  21. data.forEach(dato => { // Iteramos los datos
  22.  
  23. const miFila = fila.clone(); // Clonamos la fila.
  24.  
  25. miFila.find('img').attr('src', dato.img); // Ponemos la imagen
  26.  
  27. miFila.children('.name').html(dato.name); // Ponemos el nombre
  28.  
  29. $('#ownerT').append(miFila); // Pegamos la fila a la tabla
  30.  
  31. });
  32. });
  33. }
  34.  
  35. });
  36. //$("#ownerT").load();
  37.  
  38. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement