Akio Yanagawa
Akio Yanagawa

Reputation: 323

How to use ajax to get data from a server in phonegap?

Please pardon me asking this rudimentary question, but let me know if anyone knows about it.

I'm developing a web application for smartphones, and want to make a native application of it for iOS, Android, and so on by PhoneGap.

In my script I use Ajax in order to send and get data from a php file in a server.

$.ajax({

   url: "example.php",

   cache: false,

   data: data,

   success: function(result, dataType){

    }

});

If I change url: "example.php" in the above to, say, url: http://www.example.com/example.php, will a native application send and get data from example.php in a server?

I would appreciate if anyone who knows about it could help anserwing my question.

Thank you.

Upvotes: 0

Views: 2264

Answers (1)

jcesarmobile
jcesarmobile

Reputation: 53301

Yes, but you have to whitelist the url. whitelist documentation

And be careful with iOS 6, it caches the ajax responses, take a look to this topic iOS 6 caching problem

Upvotes: 3

Related Questions