1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    4
    Vote Rating
    1
    Romain Pennes is on a distinguished road

      0  

    Default Answered: Using PhoneGap - AJAX JSON or JSONP requests ?

    Answered: Using PhoneGap - AJAX JSON or JSONP requests ?


    Hello,

    I've been developing a Sencha Touch 1.1 project. It uses standard AJAX queries with Ext.Data.Store and JSON results. I tried the application in a browser by having the Html/JS files on the server which also returns JSON through AJAX queries.
    It works greatly in that way.

    Now, I've recently set up my Sencha Touch 1.1 project with PhoneGap to use it with Android. Which means I now have my Html/JS files wrapped in my Android app thanks to PhoneGap. The files are now in the phone, so to speak.

    But my AJAX calls on the server don't work from the android app on my phone. (Even though the server can be reached from my phone).
    I've been thinking the problem is due to the fact that i use standard AJAX JSON calls in the app.
    Since the Html and JS files are located in the phone and i try to reach a distant server for my AJAX calls, do i need to setup JSONP calls with my app instead? Shouldn't standard AJAX/JSON queries work in that case?

  2. Is your url whitelisted?

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    899
    Answers
    3575
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Is your url whitelisted?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    May 2012
    Posts
    4
    Vote Rating
    1
    Romain Pennes is on a distinguished road

      0  

    Default


    Hello, thanks for your answer.

    Is your url whitelisted?
    No it is not because the URL is entered in the app by the user to point to his personal server.

    Which means we can't know where the server is located until the user enters it in the app.
    Therefore, we can't have a whitelist.

  5. #4
    Sencha User
    Join Date
    May 2012
    Posts
    4
    Vote Rating
    1
    Romain Pennes is on a distinguished road

      1  

    Default


    Thank you for your answer, I've finally managed to make it work.

    I didn't know we could potentially allow access to any domain, which is what we need in our case.

    Code:
    <access origin=".*"/>
    Including this line to the cordova.xml made the job.

    Thanks.

  6. #5
    Sencha User
    Join Date
    Feb 2013
    Posts
    1
    Vote Rating
    0
    sdl123 is on a distinguished road

      0  

    Default


    where is cordova.xml file located?