I want to develop an iPhone native app, that sync with a remote DB.Is it possible to develop this application using PhoneGap.If I use PhoneGap, how do I get data from an externa
I just compiled a PhoneGap app with PHP using Ajax to get content.
First, load jQuery library at index.html head. At function onBodyLoad(), put the Ajax call for the PHP file:
$('#content').load('http://www.example.com/test.php');
at the HTML session, put the div id="content" where do you want to show content.
PHP:
for($i=1; $i<=10; $i++) {
echo 'I\'m a PHP Loop! Value: ' . $i . ' of 10.
';
}
HTML will print:
I'm a PHP Loop! Value: 1 of 10.
I'm a PHP Loop! Value: 2 of 10.
I'm a PHP Loop! Value: 3 of 10.
I'm a PHP Loop! Value: 4 of 10.
I'm a PHP Loop! Value: 5 of 10.
I'm a PHP Loop! Value: 6 of 10.
I'm a PHP Loop! Value: 7 of 10.
I'm a PHP Loop! Value: 8 of 10.
I'm a PHP Loop! Value: 9 of 10.
I'm a PHP Loop! Value: 10 of 10.
You could also use
$.get('test.php?name', function(data) {
$('#content').html(data);
});
And your test.php could have something like:
if (isset($_GET['name'])) {
echo "Asked for name!";
}
With this, you can go on and make some nice stuff. I have one doubt on the subject: can I host external PHP files and deploy the app on app store? There's any restrictions about that?