Reputation:
So, I created an app using jquery and what i did is I imported a function called $.ajax to accsess an api. But when I tested the app it did not work on my android phone, but on the pc it worked, so my question would be is using the $.ajax() function in phonegap possible?
Upvotes: 0
Views: 81
Reputation: 327
You need to use whitelist plugin to successfully call apis. $.ajax() will start working, once you add whitelist plugin. https://cordova.apache.org/docs/en/5.0.0/guide/appdev/whitelist/
Add following line in config.xml:
<gap:plugin name="cordova-plugin-whitelist" source="npm" />
<access origin="*" />
<allow-intent href="*" />
<allow-navigation href="*" />
Upvotes: 1
Reputation: 4406
I would advice you to debug your app using chrome: How to remote debug. This will help you a lot in debugging errors instead "guessing in the blind".
To answer your question. Yes, it is possible to use Ajax in phonegap.
Upvotes: 1