-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcomment.php
More file actions
57 lines (55 loc) · 1.36 KB
/
Copy pathcomment.php
File metadata and controls
57 lines (55 loc) · 1.36 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Comments</title>
<link rel="stylesheet" type="text/css" href="bootstrap/dist/css/bootstrap.css">
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
</head>
<body>
<div class="container">
<p> </p>
<div class="comment_listing"></div>
<h1>Post Your Comment Below</h1>
<div class="col-md-5">
<input type="text" class="name form-control" placeholder="Name"><br>
<input type="text" class="email form-control" placeholder="Email"><br>
<textarea class="comment form-control"></textarea>
<p> </p>
<a href="javascript:void(0)" class="btn btn-primary submit">Submit</a>
</div>
<div class="clearfix"></div>
</div>
</body>
</html>
<script type="text/javascript">
function listComments()
{
$.ajax({
url:'comment_list.php',
success:function(res){
$('.comment_listing').html(res);
}
})
}
$(function(){
listComments();
setInterval(function(){
listComments();
},10000);
$('.submit').click(function(){
var name = $('.name').val();
var email = $('.email').val();
var comment = $('.comment').val();
$.ajax({
url:'save_comment.php',
data:'name='+name+'&email='+email+'&comment='+comment,
type:'post',
success:function()
{
alert("Your comment has been posted");
listComments();
}
})
})
})
</script>