Note that there are some explanatory texts on larger screens.

plurals
  1. POWeb page can't retrieve data from remote server in Phonegap (but works fine in Chrome)
    primarykey
    data
    text
    <p>I am trying to create an Android application using Phonegap 3.1. The app needs to retrieve data from my remote server, which is running Apache with the <code>Header set Access-Control-Allow-Origin "*"</code> directive set for the URI the app should be pulling data from. I have <code>&lt;access subdomains='true' url='*' /&gt;</code> set in Phonegap's config.xml file. The code below works and runs the "success" function if I put the web page into a local Apache directory separate from the server (different machines on different domains in different physical locations) and call it from Chrome, but when I try to call it via Phonegap it throws a less than helpful error of <code>{"readystste":0,"responseText":"","status":0,"statusText":"error"}</code>. The <code>"readystate":0</code> looks like it might be an access or cross-site scripting error that's only happening in Phonegap, so I'm willing to believe it's something I need to configure on my end, but I'm going nuts trying to figure out what.</p> <p>Thanks for any help you can provide. I need to get this running and have been scouring the web for a week trying to get it to work.</p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;HTML&gt; &lt;HEAD&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;link rel="stylesheet" type="text/css" href="css/affirmation.css"&gt; &lt;script src="js/jquery-1.10.1.min.js"&gt;&lt;/script&gt; &lt;script&gt; $.support.cors = true; $(document).ready(function(){ $.ajax({ type: 'POST', url: 'http://www.remote.server/info/API', datatype: 'json', data: JSON.stringify( { method: 'content', params: [ 'text passed to function on server' ], id: '1' } ), success: function(response, textstatus, jqxhr) { $('#graf1').text(JSON.stringify(response)); $('#graf3').text(JSON.stringify(textstatus)); $('#graf6').text(JSON.stringify(jqxhr)); }, error: function(jqxhr, textstatus, errorthrown) { $('#graf1').text(JSON.stringify(jqxhr)); $('#graf3').text(JSON.stringify(textstatus)); $('#graf6').text(JSON.stringify(errorthrown)); } }); }); &lt;/script&gt; &lt;/HEAD&gt; &lt;BODY&gt; &lt;DIV ID="header"&gt;JSON Server Test&lt;/DIV&gt; &lt;DIV ID="content"&gt; &lt;DIV ID="graf1" CLASS="bodytext"&gt;&lt;/DIV&gt; &lt;DIV ID="graf3" CLASS="bodytext"&gt;&lt;/DIV&gt; &lt;DIV ID="graf6" CLASS="bodytext"&gt;&lt;/DIV&gt; &lt;/BODY&gt; &lt;/HTML&gt; </code></pre>
    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.
    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