Search code examples
jqueryajaxphonegap

Ajax Request Not Working on Phonegap


I should really post this question since I just can't find working solution for ajax request with phonegap.

I'm using the latest phonegap and android studio. When I previewed in in AVD, everything is fine except the ajax call.

I've also added a whitelist plugin for cordova (actually), in phonegap I've run this command:

phonegap plugin add cordova-plugin-whitelist

Anda Here is my config.xml file:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.halalprowebdesign.universityassistance" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
    <feature name="Whitelist">
        <param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin" />
        <param name="onload" value="true" />
    </feature>
    <name>University Assistance</name>
    <description>
        A blank PhoneGap app.
    </description>
    <author email="[email protected]" href="http://phonegap.com">
        PhoneGap Team
    </author>
    
    <content src="index.html" />
    <access origin="*" />
    <preference name="loglevel" value="DEBUG" />
</widget>

More over, I've make sure that the script was working properly when testing on phonegap desktop app server.

If anyone have an idea about this, I would really appreciate it.

Thanks in advance.


Solution

  • You need to replace localhost with the server address. You can't point it at localhost while it is hosted on your (internet) server.