-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage.html
93 lines (56 loc) · 2.14 KB
/
page.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Node page</title>
<!--<link rel=stylesheet href=styles.css type=text/css>
<script src="/js/scripts.js" type="text/javascript"></script>
<script src="/js/jquery.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
-->
<script src="jquery"></script>
<script>
$(document).ready(function () {
$.getJSON("sendjson", function (data) {
for (var i = 0; i < data.length; i++) {
$("#table").append("<tr>" +
"<td>" + data[i].service + "</td>" +
"<td>" + data[i].contractor + "</td>" +
"<td><button name=removeService" + i+ " type=\"button\">Удалить!</button></td>" +
// "<td><a title=\"Удалить\" href=\"/removeService/?id=" + i +"\""+'>✖</a></td>' +
"</tr>");
}
$("button[name^='removeService']").click(function (e) {
//$("button[name^='removeService']" ).on("click", "button[name^='removeService']", function (e) {
//e.preventDefault();
//alert("fdsgs");
var st=this;
$.post({
type: 'POST',
url: '/removeService',
data: this.name.substr(13),
success: function() {
$(st).parent().parent().remove();
$("#table").find("button[name^='removeService']").
each(function (index) {
if( ($(this).name!==st.name))
$(this).attr('name','removeService'+index);
})
}
/*error: function() {
alert(data);}
*/
})
})
/*
*/
})
})
</script>
</head>
<body>
<h1>Simple page</h1>
<table class="table" id="table">
</table>
</body>
</html>