Closed anonuserch closed 3 years ago
Yh I have. I'm working on a project which scans the qrcode and do some ajax calls but I want to auto restart instead of always pressing the request camera permission.
Hello everyone, has someone already extended the code to save the QR code content in a Mysql database after each scan (with Ajax -> PHP)?
yes on the onSuccessCallback you can trigger any kind of logic. Example
function saveQrContentToDb(qrMessage) {
// .. write ajax logic here
}
function onScanSuccess(qrMessage) {
saveQrContentToDb(qrMessage);
}
function onScanFailure(error) {
// skip failure conditions
}
let html5QrcodeScanner = new Html5QrcodeScanner(
"reader", { fps: 10, qrbox: 250 }, /* verbose= */ false);
html5QrcodeScanner.render(onScanSuccess, onScanFailure);
(please reopen if this is not clear enough)
Hello @mebjas
Hello everyone, has someone already extended the code to save the QR code content in a Mysql database after each scan (with Ajax -> PHP)?
yes on the onSuccessCallback you can trigger any kind of logic. Example
function saveQrContentToDb(qrMessage) { // .. write ajax logic here } function onScanSuccess(qrMessage) { saveQrContentToDb(qrMessage); } function onScanFailure(error) { // skip failure conditions } let html5QrcodeScanner = new Html5QrcodeScanner( "reader", { fps: 10, qrbox: 250 }, /* verbose= */ false); html5QrcodeScanner.render(onScanSuccess, onScanFailure);
@mebjas tried this one but it doesn't seem to push thru on my ajax. here's my code. On method "updateWaybillStatus" it alerts the qrMessage and after that nothing happens no logs on my console that it performs the ajax. Please help. Thank you.
function onScanSuccess(decodedText, decodedResult) {
updateWaybillStatus(decodedText)
html5QrcodeScanner.clear();// ^ this will stop the scanner (video feed) and clear the scan area.
}
//Inserts on database
function updateWaybillStatus(qrMessage) {
alert(qrMessage)
$.post("{{ url('/scanParcelUpdate/') }}" + "/" + qrMessage, function(data, status) {
console.log('success')
});
}
var html5QrcodeScanner = new Html5QrcodeScanner(
"reader", { fps: 10, qrbox: 250 }
);
function onScanError(errorMessage) {
// handle on error condition, with error message
}
html5QrcodeScanner.render(onScanSuccess, onScanError);
This thread is very much outside the scope of this project.
Hello everyone, has someone already extended the code to save the QR code content in a Mysql database after each scan (with Ajax -> PHP)?