-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqq.php
30 lines (29 loc) · 1.13 KB
/
qq.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
<!DOCTYPE html>
<html>
<head>
<title>QR Code Scanner</title>
</head>
<body>
<video id="preview" width="160" height="120"></video>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5-qrcode/2.0.3/html5-qrcode.min.js"></script>
<script type="text/javascript">
function onScanSuccess(decodedText, decodedResult) {
// Handle on success condition with the decoded text or result.
console.log(`Code matched = ${decodedText}`, decodedResult);
// Sending decoded text to the server using AJAX
fetch('process_qr.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: 'data=' + encodeURIComponent(decodedText)
})
.then(response => response.text())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
}
var html5QrcodeScanner = new Html5QrcodeScanner("preview", { fps: 10, qrbox: 250 });
html5QrcodeScanner.render(onScanSuccess);
</script>
</body>
</html>