1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    12
    Vote Rating
    0
    erinhir is on a distinguished road

      0  

    Default Unanswered: Eclipse + Phonegap ==> ajax call to local webserver

    Unanswered: Eclipse + Phonegap ==> ajax call to local webserver


    I have installed xampp and mysql on my windows pc. I use sencha touch 1.x. I have a website running locally. It is under "htdocs/website". It runs perfectly ;-)
    I have developped a mobile app (it is under "htdocs/mobile"). I tested the app first with google chrome. In the app there are some ajax calls to the local webserver (e.g. login of user). This works perfectly. I can send a request and I receive a response.
    I use the "Ext.util.JSONP.request" to call webservices.
    Now I installed eclipse, phonegap and ADT, created a new android project in eclipse. I start my local webserver and run my app in eclipse as an android application.
    I get no errors. Android simulator is started and the app opens. But when I make a call to my webserver nothing happens.
    What is wrong?
    thanks

  2. #2
    Sencha User
    Join Date
    Apr 2012
    Posts
    12
    Vote Rating
    0
    erinhir is on a distinguished road

      0  

    Default


    This is the code for the request

    PHP Code:
    console.log("In checkLogin of logincontroller");

        
    Ext.util.JSONP.request({
            
    url'http://mywebsite/mobile/login.php',
            
    paramsoptions.data,
            
    callbackKey"callback",
            
    scopethis
            
    callback: function(response) {
                
    console.log("success");
                if (
    response.success == "true")
                {
                    
    //save login locally on phone
                    
    this.index(options);
                }
                else {
                    
    Ext.Msg.alert(response.errors.reason'');
                    
    console.log("failure");
                }
            }
        }); 
    I also have a cordova.xml file in the res/xml folder. With following content:

    PHP Code:
    <?xml version="1.0" encoding="utf-8"?>
    <cordova>
        <!--
        access elements control the Android whitelist.
        Domains are assumed blocked unless set otherwise
         -->
        <access origin="http://mywebsite" /> <!-- allow local pages -->

        <!-- <access origin="https://example.com" /> allow any secure requests to example.com -->
        <!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www -->
        <access origin=".*"/>

        <log level="DEBUG"/>
        <preference name="useBrowserHistory" value="false" />
        <preference name="exit-on-suspend" value="false" />
    <plugins>
        <plugin name="App" value="org.apache.cordova.App"/>
        <plugin name="Geolocation" value="org.apache.cordova.GeoBroker"/>
        <plugin name="Device" value="org.apache.cordova.Device"/>
        <plugin name="Accelerometer" value="org.apache.cordova.AccelListener"/>
        <plugin name="Compass" value="org.apache.cordova.CompassListener"/>
        <plugin name="Media" value="org.apache.cordova.AudioHandler"/>
        <plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
        <plugin name="Contacts" value="org.apache.cordova.ContactManager"/>
        <plugin name="File" value="org.apache.cordova.FileUtils"/>
        <plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
        <plugin name="Notification" value="org.apache.cordova.Notification"/>
        <plugin name="Storage" value="org.apache.cordova.Storage"/>
        <plugin name="Temperature" value="org.apache.cordova.TempListener"/>
        <plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
        <plugin name="Capture" value="org.apache.cordova.Capture"/>
        <plugin name="Battery" value="org.apache.cordova.BatteryListener"/>
        <plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
        <plugin name="Echo" value="org.apache.cordova.Echo" />
    </plugins>
    </cordova>

  3. #3
    Sencha User
    Join Date
    Aug 2010
    Posts
    303
    Answers
    3
    Vote Rating
    3
    steve1964 is on a distinguished road

      0  

    Default


    Hi, you dont have access to localhost on real device (http://127.0.0.1) you have to make your call to a public ip or read this:
    http://stackoverflow.com/questions/3...android-device

  4. #4
    Sencha User
    Join Date
    Apr 2012
    Posts
    12
    Vote Rating
    0
    erinhir is on a distinguished road

      0  

    Default


    Using ip 10.0.2.2 does the trick

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi