XMLHttpRequest In Gears
The XMLHttpRequest object is implemented in Gears, which turn it into a special Ajax framework whose aim is mainly to use web applications offline.
Features of the XHR object are so extendend and is is able to exchange Blobs or texts between the browser on a side and on the other side the server or the local computer.
To use XHR in Gears:
- Install the plug-in on your browser.
- Include the gears_init.js script (see resources belows to get it).
The difference with the classic Ajax code is the use of google.gears.factory.create('beta.httprequest') to create the object, which alone replaces constructors for different browsers (See XHR for details).
The above example loads the xhr-demo.txt file that contains the string "Hello World!"
And the contents of the file is displayed in the <div> whose ID is "storage".
Demonstration : XMLHttpRequest in gears
Using the XMLHttpRequest object in Gears. The object is created by the Google's API that in turn will use the right constructor for the current browser.
If the Gears plug-in is installed on the browser, the message "Hello World!" must be displayed below in big letters: