3 Replies Latest reply on Apr 2, 2014 12:49 AM by Kutir Mobility

    rhodes app with barcode scanner api showing error at rho_javascript_api.js:85

    Priyanka Singh

      Hi,I have created a rhodes app with barcode scanner api integrated using javascript. i am using rhomobile suit 2.2 for developing this app. when i run this app on my android device iam getting the following error. Please help:----E/Web Console( 6350): Uncaught TypeError: Object function (e,t){return new b.fn.init(e,t,r)} has no method 'toJSON' at http://localhost:36176/public/js/rho_javascript_api.js:85

        • Re: rhodes app with barcode scanner api showing error at rho_javascript_api.js:85
          Kutir Mobility

          Hi Priyanka,

          Could you please share your code snippet?

           

          Visnupriya R

          Kutir Mobility

            • Re: rhodes app with barcode scanner api showing error at rho_javascript_api.js:85
              Priyanka Singh

              Here it is:

               

              <html>

              <head>

                <title>Barcode Scanner Application</title>

                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

                  <meta name="format-detection" content="telephone=no" />

                <meta name="viewport" content="width=device-width,user-scalable=no,height=device-height initial-scale=1">

               

                <link rel="stylesheet" href="./css/themes/default/jquery.mobile-1.3.2.min.css">

                <script src="./jquery/jquery-1.9.1.min.js"></script>

                <script src="./jqmobile/jquery.mobile-1.3.2.js"></script>

                <script type="text/javascript" charset="utf-8" src="./js/rho_javascript_api.js"></script>

               

               

               

               

               

                <script language="javascript">

                var scanners;

                function fnDefaultScan(){

                Rho.Barcode.take_barcode(scan_received, { });

                }

               

               

               

               

               

                function scan_received(params) {

                if (params.status == "ok") {

                alert('Barcode scanning complete. Scanned barcode: ' + params.barcode);

                } else {

                alert('Barcode scanning aborted');

                }

                Rho.Barcode.stop();

                }

               

                function choose_scanner(){

               

               

                scanners = Rho.Barcode.enumerate();

               

                var scanner_elements = "";

               

               

                for (var i = 0; i < scanners.length; i++) {

                var scanner = scanners[i];

                scanner_elements += "<a href='#' data-role='button' onclick='scan_using_chosen_scanner(" + i + ")'>" + (scanner.friendlyName || scanner.scannerType) + "</a>";

                }

               

                $("#list2").html(scanner_elements).trigger("create");

              }

               

               

              function scan_using_chosen_scanner(scanner_index) {

                  var scanner = scanners[scanner_index];

                  Rho.Barcode.allDecoders = false;

              // ... and enable only the one we are interested in:

              Rho.Barcode.upca = true;

                  scanner.take({ }, scan_received);

              }

               

               

               

               

               

               

              </script>

              <style type="text/css">

              .headerBarcodeApp{

                position: absolute;

                height: 10%;

                width: 100%;

                top: 0%;

              padding:0%;

              overflow:hidden;

              }

               

               

              .contentBarcodeApp {    

                position: absolute;

                top: 0%;

                height: 100%;

                width: 100%;

                padding:0%;

                background-image:url('./images/android/bg.jpg');

                background-repeat:no-repeat;

                background-size: 100% 100%;

                margin:0%

               

               

              }

               

               

              .footerBarcodeApp {

              position:absolute;

                height: 10%;

                width: 100%;

                 bottom: 0;

                 padding:0%;

                 text-align: center;

                 bottom: 0%;

                overflow:hidden;

              }

               

               

              #mainList{

              position: absolute;

                top: 15%;

                 width: 80%;

                padding:0%;

                text-align: center;

                left: 10%;

              }

               

               

              #list2 {

                position: absolute;

                top: 25%;

                 width: 60%;

                padding:0%;

                text-align: center;

                left: 20%;

              }

               

               

              </style>

              </head>

              <body>

               

               

              <div data-role="page" style="padding:0%">

              <div data-role="content" class="contentBarcodeApp">

              <div data-role="header"class="headerBarcodeApp" style="text-align: center;">

                </div>

               

                <div id="mainList">

                <ul data-role="listview">

                  <li><a  onclick="fnDefaultScan();">Scan using default scanner</a></li>

                  <li><a  onclick="choose_scanner();">Select scanner to use</a></li>

                  </ul>

                  </div>

                 

                  <div id="list2" style="margin:20%">

                  </div>

                  <div data-role="footer" class="footerBarcodeApp" >

                </div>

                 

                  </div><!-- /content -->

               

              </div><!-- /page -->

               

               

              </body>

               

               

               

               

              </html>