-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathapp.js
45 lines (39 loc) · 1.4 KB
/
app.js
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
36
37
38
39
40
41
42
43
44
45
$(document).ready(function() {
$.get("view.php", function(data) {
$("#table_content").html(data);
});
$('#link-add').hide();
$('#show-add').click(function() {
$('#link-add').slideDown(500);
$('#show-add').hide();
});
$('#add').click(function() {
var name = $('#name').val();
var username = $('#username').val();
var password = $('#password').val();
$.ajax({
url: "add.php",
type: "POST",
data: { name: name, username: username, password: password },
success: function(data, status, xhr) {
$('#name').val('');
$('#username').val('');
$('#password').val('');
$.get("view.php", function(html) {
$("#table_content").html(html);
});
$('#records_content').fadeOut(1100).html(data);
},
error: function() {
$('#records_content').fadeIn(3000).html('<div class="text-center">error here</div>');
},
beforeSend: function() {
$('#records_content').fadeOut(700).html('<div class="text-center">Loading...</div>');
},
complete: function() {
$('#link-add').hide();
$('#show-add').show(700);
}
});
}); // add close
}); // document ready close