5 Replies Latest reply on Jun 20, 2012 7:13 PM by Stuart Hume

    JQuery getJSON Problem

      I am trying to get a sample app running, that will read a local json file for testing.  I have the latest rhoelements runtime running fine, the script is firing on a button press.


      The file test.json is { "ABC" : "123" } and it is in the rootfolder for the device (a mc9190g). ( have tried it in various subfolders - with slashes).


      $.getJSON('test.json',  function(data) { alert('HELLO');} );


      -- I would expect this to at least fire the alert box with the word HELLO in it.


      Jscript after this works fine, and I am using jquery to update values - so I know that is loading fine.


      IS getJSON not supported or is there something fundamental I am missing? (like I can't read from the local file system?)



        • Re: JQuery getJSON Problem
          Darryn Campbell

          Hi Stuart,


          Presuming you're running a native Rhodes / Rhoelements application then the root folder will actually be <your app>/rho/apps/ (or something like that), not the root of the device.



            • Re: JQuery getJSON Problem

              Thanks Darryn

              I tried that - its a hybrid application - just a simple html file, loaded at start up by the rhoelements runtime.

              The config.xml (\Program Files\RhoElements\..) is set to point to the index.html which is in "\Grading\index.html' (Grading folder is off the root folder).

              This all works fine. 


              The file is simple. - no difference, so it seems to be something else, as I can not get the callback to fire.

              I have tried various paths to the test.json file (root folder, .../rho/apps/test.json, /Grading/test.json) etc, and no luck.

              I tried a URL to an external website that returns JSON (I can get the JSON restul through IE by calling a get URL no problem)


              At the end, the input value for "UMB" is indeed updated to ABC....


              Here is the code ...




                    <title>Hello Scan</title>

                    <meta http-equiv="scanner"

                                   content="DecodeEvent:url('Javascript:doScanDecode('%1', '%2', '%6');'); enabled" />

                    <meta http-equiv="quitbutton" content="visibility:visible;" />


                    <META HTTP-Equiv="KeyCapture" Content="KeyValue:0x0D; RemapTo:0x09">

                    <META HTTP-Equiv="KeyCapture" content="KeyValue:0x25; RemapTo:0x08">

                    <script type="text/javascript" src="/Grading/jquery-1.6.4.min.js"></script>



                    function fnSubmitGradingForm()



                      var jsonPath = '/Grading/test.json' ;


                      $.getJSON(jsonPath,  function(data) { alert('HELLO');} );






                    Scan Carcass Ticket

                    <div id='divOutput'>

                      <p id='sDetails'>Scan Details</p>



                    <div id='gradingInputs'>

                      <p>Grading Inputs</p>

                      <form id='GradingForm'>

                      UMB :<input size='3' type='text' value='500' id='UMB' /><br/>

                      OSS :<input size='3' type='text' value='220' id='OSS'/><br/>

                      PHU :<input size='3' type='text' value='5.1' id='PH'/><br/>

                      TEMP:<input size='3' type='text' value='2.5' id='TEMP'/><br/>

                      HUMP:<input size='3' type='text' value='50' id='HUMP'/><br/>

                      <input type='button' value='GRADE' onclick='fnSubmitGradingForm()' />