2 Replies Latest reply on Jan 27, 2014 9:23 AM by Daniel Silva

    SB1 demo app - responseXML returns null

      I am trying to build demo Inventory Look up App for SB1 and trying to read sample data from a XML file (ref. below js code). But it seems responseXML returns null value. However, if I run this code on my laptop, it does return value according to jsonObject. Any idea?

       

      function decodeEvent

      (jsonObject)
      {
      var foundRec
      = false;
      if
      (window.XMLHttpRequest)
      {
      // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp
      =new XMLHttpRequest();
      }
      else
      {
      // code for IE6, IE5 11.
      xmlhttp
      =new ActiveXObject("Microsoft.XMLHTTP");
      }
      xmlhttp
      .open("GET", "http://127.0.0.1:83/Application/www/apps/invlookup/products.xml",false);
      xmlhttp
      .send(null);

      if
      (xmlhttp.status==200) {
      var xmlDoc
      = xmlhttp.responseXML;
      var prods
      =xmlDoc.childNodes[0];

      for
      (var i = 0; i < prods.children.length; i++) {
      var prod
      = prods.children[i];
      var code
      = prod.getElementsByTagName("code");
      var item
      = prod.getElementsByTagName("item");
      var desc
      = prod.getElementsByTagName("description");
      var qty
      = prod.getElementsByTagName("qty");

      if
      (code[0].textContent.toString() == jsonObject.data) {
      foundRec
      = true;
      resetstoreqty
      ();
      document
      .getElementById('info1').innerHTML = code;
      document
      .getElementById('info2').innerHTML = item;
      document
      .getElementById('item').innerHTML = description;
      document
      .getElementById('qty').innerHTML = qty;
      document
      .getElementById('priceLookup').className = '';
      document
      .getElementById('information').className = 'hidden';
      setTimeout
      (function(){document.getElementById('details').style.maxWidth = 320},300);
      asl
      .back(function()
      {
      document
      .getElementById('priceLookup').className = 'hidden';
      document
      .getElementById('information').className = '';

      asl
      .back(exit);
      }
      );
      }
      }

      if
      (!foundRec)
      {
      document
      .getElementById('scan_error').className = '';
      setTimeout
      (function()
      {
      document
      .getElementById('scan_error').className = 'hidden';
      }
      , 1000);
      }
      }
      else if
      (xmlhttp.status==404) {
      alert
      ("XML could not be found");
      }
      }

        • Re: SB1 demo app - responseXML returns null
          Kutir Mobility

          Hi Jitul,

          1. What was the http status you get when you print xmlhttp.status ?

          2. Does it also print null when you print xmlhttp ?

          3. Have you tried reading remote or local json object instead ?

           

          Thank you,

          Visnupriya R

          • Re: SB1 demo app - responseXML returns null
            Daniel Silva

            A few thoughts. 

            First, I would not recommend putting anything under the application folder as it appears you are doing here.  Please use the UserDrive folder instead.  The \Application folder is meant to be used by system software and will be wiped out every time the OS needs to be updated.  Also, if you filled it or corrupted it somehow, the device could end up being hard or impossible to recover.

             

            Depending on how you have your apps.json set, you might possibly have a cross domain issue.  You would want it set like

            "url": "http://127.0.0.1:83/UserDrive/apps/test1.html",

            not

            "url": "/UserDrive/apps/test1.html",

             

            One thing that might help is to pull the log.txt file from the root of the userdrive and take a look at that.  That will many times show an error that might help you figure out what the issue is.