androidhtmlajaxintel

Intel XDK v0876: $.get() not working on device via App Preview (Android nor WIndows), but works in emulator


I have the following code in a Intel XDK project that is fully working in the emulator but the Ajax $.get() call does return data on Android or Windows in App Preview:

    <script>
        function updateBalancePageContent() {
               var balanceUrl = 'http://cryptexplorer.com/chain/Uro/q/addressbalance/URKzLbuvyjvg9rnT8Ezdu4jYiZJTQETwbh';
            
               $.get(balanceUrl, function(data) {
                  $("#acc-bal-lbl").text("Balance: " + data);
               }); 
                              
            }); 
        
    </script>

<p id="acc-bal-lbl"></p>
<a class="icon info" href="javascript:switchSubPage('uro-balance-page'); updateBalancePageContent();">BALANCE</a>

Any ideas where I should start to solve this problem?

When I use the Weinre based live debugger and try to do a $.get("http://google.com"); in the console, the resulting XMLHttpRequest has no responseText.


Solution

  • You are experiencing an issue associated to Cross Origin Resource Sharing. I recommend that you include a reference to the xhr.js script in the head tag of your index.html file. This should resolve this issue.

    <script src="xhr.js"></script>