diff -r 4d198a32ac7d -r d4809db37847 plugins/org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-46FA9398-10C1-429F-B496-EC70E88F9CC7.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-46FA9398-10C1-429F-B496-EC70E88F9CC7.html Thu Aug 19 17:48:04 2010 -0700 @@ -0,0 +1,21 @@ + + +Retrieving data

Retrieving data

You can retrieve content either from the device or from Web sites. Make the content dynamic rather than static. To keep response times short and avoid cluttering the screen, display only content that users requested.

+

Fetching content from mobile devices

You can use the GetList methods in the JavaScript Service API reference to fetch content from mobile devices that support Web Runtime (WRT) 1.1. For more information about the content that you can fetch, see Using platform services.

You can combine content from the device with content from Web sites.

+

Fetching content from Web sites

You can use the following ways to fetch content from Web sites:

    +
  • HTTP requests

  • +
  • JavaScript Document Object Model (DOM)

  • +
  • Asynchronous JavaScript and XML (AJAX)

  • +

Allow network connections from widgets in the info.plist file. For more information see, Creating the info.plist file.

+

Using HTTP requests

You can use HTTP requests to retrieve data from Web services. You can use the HTTP GET or HTTP POST method to send parameters to Web services through the Representational State Transfer (REST) API. The services return results as a JavaScript Object Notation (JSON) object or XML text. Use the HTTP POST method to retrieve data from SOAP services.

For an example, see Retrieving STEW data.

Note: Set the

Expires response header of the HTTP server reply to minimize the network round-trips to the server. The header tells the application that the file can be cached locally for the specified duration, and is not fetched repeatedly from the server with each page load.
+

Using JavaScript DOM

Use JavaScript to manipulate content dynamically. The DOM functions include document.createElement() and elem.appendChild().

+

Using AJAX

AJAX is a technique that combines JavaScript (or any ECMAScript compatible language), XML (or other transport format), and an object called XMLHttpRequest that allows Web applications to send asynchronous calls to the server without refreshing the page. While the request is going to the server, the user can continue using the page for reading or selecting things.

AJAX uses the following:

    +
  • XHTML as markup language and CSS as styling information.

  • +
  • DOM accessed with a script language.

  • +
  • XMLHttpRequest object to communicate with the server asynchronously.

  • +
  • XML as the message format to transfer data.

  • +

Use AJAX to avoid refreshing pages and to load data faster. Only a portion of the page is transferred, which reduces traffic and communication time.

The mobile device keypad is difficult to type with and makes user input slow. Sites created using AJAX offer also the possibility to auto-fill input fields based on predictive text or previous user entries. For an example, see STEW: managing user interaction

Note: Be conservative with AJAX calls. Do not poll frequently or do not poll at all. Maybe only use AJAX on demand. Fetch all the data in a single AJAX call instead of performing many smaller calls. Use XML format and parse each piece of data from the reply with the standard DOM functions. Send straight XHTML to avoid excessive parsing in the browser.

For examples of using AJAX, see AccuWidget Example and Getting Started With Ajax - Overview and Examples.

+
\ No newline at end of file