Search code examples
androidsencha-touchsencha-touch-2localhostjsonp

Testing jsonp request from hybrid mobile app (sencha touch) on localhost


I have a rails server running on a local pc with an api to serve some data to the client hybrid mobile app, which is coded with the Sencha Touch framework.

If I test my mobile app on a browser of another pc connected to the same router, the jsonp request to my local server

url: 'http://192.168.1.34:3000/api/login'

works good, but if I test this app compiled for android with the same request in a mobile device it doesn't work.

Here is the JSONP code:

Ext.data.JsonP.request({
            url: 'http://192.168.1.34:3000/api/login',
            callbackKey: 'callback',
            params: {
                "username": username,
                "password": password,
                format: 'json',
            },
            callback: function (response,data){
             ...
            }

Solution

  • Here the solution, I added some access origin lines to the config.xml: Whitelist Guide