document ready function ajax type GET url accounts php data action sta

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$(document).ready(function() {
$.ajax({
type: "GET",
url: "accounts.php",
data: { action: 'start' },
success: function(response){
var allRows = JSON.parse(response);
$.each(allRows, function(rowIndex, row) {
var tr = $(document.createElement('tr'));
$.each(row, function(index, value) {
if (index == 'id' || index == 'description') return true;
tr.append('<td>'+value+'</td>');
});
tr.appendTo($('tbody'))
});
}
});
$(document).on( 'click', 'tbody tr td:first-child', function() {
var num = $(this).text();
var td = $(this);
$.ajax({
type: "GET",
url: "accounts.php",
data: { number: num },
success: function(response){
$(td).append('<div class="description"><b>Description</b>: '+response+'</div>');
}
});
});
$(document).on( 'click', 'html', function() {
$('.description').remove();
});
});