Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery Get function wont work when on a real mobile device
    primarykey
    data
    text
    <p>I have been working on an app that collects a csv file from dropbox and then display's it. Since I am using phonegap I have been developing and testing with a browser, Firefox to more precise. At the end of the day I loaded it on to my HTC tablet with android 3.2.1 and it just didn't work. Here's the code currently used:</p> <pre><code>$.get('https://dl.dropboxusercontent.com/u/53792213/App/David.csv', function(data) { alert('Success'); // Do stuff }) .fail(function() { alert('error'); }); </code></pre> <p>This code works absolutely fine in Firefox and on an android emulator with android 4.2.2. But not on the real physical device.</p> <p>I simply cannot work it out. No errors are given, and the fail function is never called. Both alert's I have added don't fire. </p> <p>It is extremely frustrating as I don't have access to remote debugging, and I can't debug on the desktop as it works fine on the desktop.</p> <p>I am using jquery 2.0.2 along with jquery mobile 1.3.1</p> <p>I'd appreciate even the slightest clue as to what is going on.</p> <p>EDIT: In order to find out about the error, now that it is infact throwing an error I modified my statement to this:</p> <pre><code>$.get('https://dl.dropboxusercontent.com/u/53792213/App/David.csv', function(data) { alert('Success'); // Do stuff }) .fail(function(jqXHR, textStatus, errorThrown) { alert("An AJAX error occured: " + textStatus + "\nError: " + errorThrown); }); </code></pre> <p>However this is the error it returns: </p> <pre><code>An AJAX error occured: error Error: </code></pre> <p>A blank error message? Either I'm doing something wrong or javascript wants to kill me slowly.</p> <p>EDIT 2:</p> <p>After doing some experiments I have discovered more strange behaviour. If I add the get() function directly into my deviceReady function, as in it will get fired when the app is loaded and ready to go, it works perfectly.</p> <p>But (and this is what has been happening) if I bind a click jquery event in the device ready function, and then call the get function inside it, it doesnt work. Here have a look at this:</p> <pre><code>var App = { // Application Constructor initialize: function() { this.bindEvents(); }, bindEvents: function() { document.addEventListener('deviceready', this.onDeviceReady, false); }, onDeviceReady: function() { //This does work $.get('http://dl.dropboxusercontent.com/u/53792213/App/DavidColson.csv', function(data) { alert('Success'); }) .fail(function(jqXHR, textStatus, errorThrown) { alert("An AJAX error occured: " + textStatus + "\nError: " + errorThrown); }); $("#Button").bind("click", function(event) { alert("Hello"); //This does not work $.get('http://dl.dropboxusercontent.com/u/53792213/App/DavidColson.csv', function(data) { alert('Success'); }) .fail(function(jqXHR, textStatus, errorThrown) { alert("An AJAX error occured: " + textStatus + "\nError: " + errorThrown); }); }); }, </code></pre> <p>};</p> <p>In the above situation the hello alert fires, but not the success alert, instead I get a blank ajax error. Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload