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
34
35
$(document).ready(function() {
$.ajax({
type: "GET",
url: "accounts.php",
data: { action: 'start' },
success: function(tableData){
var data = JSON.parse(tableData);
$.each(data, function(arrayIndex, array) {
$('tbody').append('<tr></tr>');
var i = 1;
$.each(array, function(index, value) {
if (index == 'id' || index == 'description') return true;
$('tr').eq(i).append('<td>'+value+'</td>');\
console.log(i);
});
i++;
});
}
});
var td = $(this);
$('table tr td:first-child').click(function() {
var num = $(this).text();
$.ajax({
type: "GET",
url: "accounts.php",
data: { number: num },
success: function(response){
$(td).append('<div class="description"><b>Description</b>: '+response+'</div>');
}
});
});
$('table tr td:first-child').mouseout(function() {
$(this).children('div').remove();
});
});