-
Notifications
You must be signed in to change notification settings - Fork 0
/
rabbit-mq.html
35 lines (31 loc) · 1.02 KB
/
rabbit-mq.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Socket.IO chat</title>
</head>
<body>
<div>
<button id="sendButton">Send Notification</button>
</div>
<script src="/socket.io/socket.io.js"></script>
<script>
document.getElementById('sendButton').addEventListener('click', function() {
var xhr = new XMLHttpRequest();
xhr.open('POST', '/send-notification', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
console.log('Notification sent successfully')
} else {
console.log('Failed to send notification')
}
}
};
var message = { message: 'Your notification message here' }; // Thay đổi nội dung thông điệp tại đây
xhr.send(JSON.stringify(message));
});
</script>
</body>
</html>