01.
$(document).ready(
function
() {
02.
increaseNotify();
03.
setInterval(increaseNotify, 10000);
04.
function
increaseNotify(){
05.
$.ajax({
06.
url:
"increase.php"
,
07.
type:
"POST"
,
08.
datatType:
'json'
,
09.
success:
function
(count) {
10.
if
(count.c_orders > 0){
11.
$(
'.orders'
).html(count.c_orders);
12.
$(
"#orders"
).html(count.c_orders);
13.
document.getElementById(
"orders"
).innerHTML= count.c_orders;
14.
sound_orders();
15.
}
16.
if
(count.c_request > 0){
17.
$(
'.request'
).html(count.c_request);
18.
$(
"#request"
).html(count.c_request);
19.
document.getElementById(
"request"
).innerHTML= count.c_request;
20.
}
21.
},
22.
error: ( jqXHR, exception)=>{
23.
var
msg =
''
;
24.
if
(jqXHR.status === 0) { msg =
'Not connect.\n Verify Network.'
;
25.
}
else
if
(jqXHR.status === 404) { msg =
'Requested page not found. [404]'
;
26.
}
else
if
(jqXHR.status === 500) { msg =
'Internal Server Error [500].'
;
27.
}
else
if
(exception ===
'parsererror'
) { msg =
'Requested JSON parse failed.'
;
28.
}
else
if
(exception ===
'timeout'
) { msg =
'Time out error.'
;
29.
}
else
if
(exception ===
'abort'
) { msg =
'Ajax request aborted.'
;
30.
}
else
{ msg =
'Uncaught Error.\n'
+ jqXHR.responseText;
31.
} alert( msg);
32.
}
33.
});
34.
}
35.
function
sound_orders(){
36.
var
audio =
new
Audio(
'./sound/orders.mp3'
);
37.
audio.play();
38.
}
39.
});