Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.73 KB | None | 0 0
  1. function show() {
  2.         $.getJSON('/request.php?tabulka', function (data) {
  3.             var body = $('table tbody');
  4.  
  5.             body.html(null);
  6.  
  7.             $.each(data, function (key, clovek) {
  8.                 body.html(`<tr id="${clovek.id}">` +
  9.                     `<td id="id">${clovek.id}</td>` +
  10.                     `<td id="name">${clovek.name}</td>` +
  11.                     `<td id="admin">${clovek.admin}<button onclick="zmen(this.parentNode.parentNode.id)">Zmeniť</button></td>` +
  12.                     `</tr>`);
  13.             });
  14.         });
  15.     }
  16.  
  17.     function zmen(id) {
  18.         $.getJSON(`request.php?zmen=${id}`, function (data) {
  19.             if (data) {
  20.                 show();
  21.             }
  22.         });
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement