-
Notifications
You must be signed in to change notification settings - Fork 2
/
footer.php
109 lines (78 loc) · 2.82 KB
/
footer.php
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script>
jQuery(document).ready(function(){
jQuery("#add_ans").on('click',function(){
var qn_id = <?php echo $qn_id?>;
var answer_content = $.trim($(".answer_content").val());
if(answer_content!=''){
$.ajax({
url:'add_answer.php',
data:'ans_content=' + answer_content + '&qn_id=' + qn_id,
success:function(msg){
if(msg=='success'){
location.reload();
} else if(msg=='abused_failed'){
alert('Offensive words found! Unable to post your answer.')
} else {
alert('Unable to post answer!');
}
}
});
}else{
alert('Enter an answer to post!')
}
});
// updating the view with notifications using ajax
// function load_unseen_notification(view = '')
// {
// $.ajax({
// url:"fetch.php",
// method:"POST",
// data:{view:view},
// dataType:"json",
// success:function(data)
// {
// $('.dropdown-menu').html(data.notification);
// if(data.unseen_notification > 0)
// {
// $('.count').html(data.unseen_notification);
// }
// }
// });
// }
// load_unseen_notification();
// // load new notifications
// $(document).on('click', '.dropdown-toggle', function(){
// $('.count').html('');
// load_unseen_notification('yes');
// });
// setInterval(function(){
// load_unseen_notification();;
// }, 5000);
// });
// jQuery(".dropdown").on('click',function(){
// $.ajax({
// url:'seen_notification.php',
// data:'msg=msg',
// success:function(){}
// });
// });
function loadDoc() {
setInterval(function(){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
responseArr = JSON.parse(this.response);
document.getElementById("dropdown_menu").innerHTML = responseArr['notification'];
document.getElementById("count").innerHTML = responseArr['unseen_notification'];
}
};
xhttp.open("GET", "data.php", true);
xhttp.send();
},1000);
}
loadDoc();
});
</script>