Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting Phonegap app to communicate to Codeigniter Server in Android and Access-Control-Allow-Origin error
    primarykey
    data
    text
    <p>I am extremely new to using phonegap,codeigniter and jQuery Mobile (My first project) and have currently created an app with jQuery Mobile on the Client side and on the Server side I used the Codeigniter framework to create a RESTful API. Now when I am developing locally the app with in the browser (not yet using phonegap) communicates just fine with the API and no problems occur. </p> <p>I placed the Codeigniter API on a server yesterday and I am now encountering 2 problems:</p> <ul> <li><p>The App which was built using jQuery Mobile keeps getting the following error:</p> <p>Origin localhost is not allowed by Access-Control-Allow-Origin.</p></li> </ul> <p>Now I have done some reading up and most people say to use jsonp instead of json and also to use the following on the Server Side:</p> <pre><code>$CI-&gt;output-&gt;set_header("Access-Control-Allow-Origin: *"); $CI-&gt;output-&gt;set_header("Access-Control-Expose-Headers: Access-Control-Allow-Origin"); $CI-&gt;output-&gt;set_status_header(200); $CI-&gt;output-&gt;set_content_type('application/json'); </code></pre> <p>Now my problem is I'm not entirely sure which one is used to fix the problem, weather it is both that need to be implemented etc. If they need to be fixed, how is it done? Is there a place that is well documented that can teach me how to deal with this problem, preferably I would like some where to read up on so I can learn?</p> <ul> <li><p>The second problem is when I place the jQuery Mobile app into phonegap and build it for Android. The app fails to get the data from the server. Now is the reason for this because of the cross domain error above or is this problem different? I also did some reading up in this section as well and to my Android config.xml I added the following code:</p> <p></p></li> </ul> <p>But I'm I still can't pull anything from the server. Like I said I'm a bit of a newbie but would really appreciate some help in this matter. Also I am aware that I haven't posted code but based on the comments I'll post which ever code the community needs to help solve this problem, just simply specify which code. Thank you for the help in advance! </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.
    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