0

I am trying to get my mobile web application scan a QR code. On scanning the entire JSON is getting populated into one single field. It's not getting parsed and populated properly.

On seeing the developer tools, I'm getting

12Failed to decode downloaded font:

12OTS parsing error: Failed to convert WOFF 2.0 font to SFNT


Edit: I think both the errors have nothing to do with QR code scanning. These are errors are coming when ever the text field is touched. Bascially how is Honeywell device dealing the QR code. Does it call some default JavaScript functions?

The JavaScript and HTML is like,

onScan: function QRScan(scannedData) {

    if (!scannedData || !scannedData.data) {
        return;
    }

    if (scannedData && (scannedData.type === 'AZTEC' || scannedData.type === 'QR')) {
        var data;
        try {
            data = JSON.parse(scannedData.data.trim() || '{}');
        } catch (e) {
            alert(e.message);
        }

        this.$('input#fname').val(data.a);
        this.$('input#lname').val(data.b);
        this.$('input#city').val(data.c);
        this.$('input#phone').val(data.d);
        this.$('input#email').val(data.e);
    }
}
<!DOCTYPE html>
<html>
<body>

  <h1>Sample HTML</h1>
  <form onsubmit="myFunction()">
    <label for="fname">First name:</label>
    <input type="text" id="fname" name="fname"><br><br>
    <label for="lname">Last name:</label>
    <input type="text" id="lname" name="lname"><br><br>
    <label for="lname">City:</label>
    <input type="text" id="city" name="city"><br><br>
    <label for="lname">Phone:</label>
    <input type="text" id="phone" name="phone"><br><br>
    <label for="lname">Email:</label>
    <input type="text" id="email" name="email"><br><br>
    <input type="submit" value="Submit">
  </form>        

</body>
</html>

Related question

DNèp
  • 47
  • 6
  • What have you tried to resolve the problem? Where are you stuck? What **exactly** is not working? Wouldn't it be easy to use `console.log` to see which data was read, and how it was parsed? – Nico Haase Jun 07 '23 at 08:40
  • @NicoHaase yes as of now I don't have access to change the code and add console logs. I'm trying to debug using dev tools, but there are no console logs. Will try to change the code once I get access. – DNèp Jun 07 '23 at 09:41

0 Answers0