O'Reilly logo

PhoneGap 4 Mobile Application Development Cookbook by Zainul Setyo Pamungkas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with remote data and AJAX requests

With a vast array of remote servers exposing their services as accessible APIs, you can create some truly dynamic applications by pulling and pushing data to and from external applications and providers.

How to do it...

We will use the XHR method within the XUI library to request data from a remote server, making an asynchronous call to obtain the results from a search:

  1. Firstly, create a new PhoneGap project named ajax by running the following line:
    phonegap create ajax com.myapp.ajax ajax
    
  2. Add the devices platform. You can choose to use Android, iOS, or both:
    cordova platform add ios
    cordova platform add android
    
  3. Open www/index.html and clean up the unnecessary elements. Include a reference to the XUI JavaScript ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required