Note that there are some explanatory texts on larger screens.

plurals
  1. POCross-domain AJAX request behaving oddly on Android phone's native browser
    primarykey
    data
    text
    <p>My setup is like so:</p> <ul> <li>An SQLite database sits in one of my Apache folders</li> <li>A Perl cgi script sits in the same folder, with public permissions, so that it can handle database interactions</li> <li>A C program, running on the same machine, listens on a specific port for specific JSON requests and responds with specifically-formatted JSON data </li> </ul> <p>A webpage, written primarily in jQuery and HTML, must access both the SQLite database and the C program somewhat constantly. It does so using AJAX requests -- here's an example from the code:</p> <pre><code>function sendCommand(cmd, callback) { $.ajax({url: "http://192.168.42.90:6112/?cmd=" + cmd, dataType: "jsonp", success: function(d,s,x) { callback(d); }, jsonpCallback: "json", error: function(xhr) { alert('Error: ' + xhr.status); } }); } </code></pre> <p>So I might invoke it with something like sendCommand("get_x", updatePosition) -- so that it'd send the get_x command along to the C program, and, if it got good feedback, run said feedback through the updatePosition function.</p> <p>So all of this works SPLENDIDLY if I'm running on a webpage on the same machine. If I move to another machine -- in this case, specifically, an Android phone, doing tethered IP over USB, it ... sort of works. This is what's puzzling me -- it doesn't silently fail, like I'm used to JavaScript doing. Instead, as far as I can tell, it sends the request out, claims that it got data back, and runs the callback function -- only, according to the C program, nothing ever happened; according to Wireshark, no packets were sent; and the "data" that it gets back is an empty, specially-formatted string. If I'm expecting "(5,5)" as output from C, it's getting "(0,0)" -- why is it getting anything at all? Much less filling "(,)" with 0s?</p> <p>Very strange. I've tried various little things, like changing the dataType to "json", making sure all my permissions are set up right, etc. I'm fairly sure that Apache isn't interfering, since there's nothing in the logs -- what gets me is that I don't see anything on Wireshark, of all things. It's like the phone just plain isn't trying to make the request.</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.
    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