org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-46FA9398-10C1-429F-B496-EC70E88F9CC7.html
author Eugene Ostroukhov <eugeneo@symbian.org>
Tue, 20 Apr 2010 17:11:57 -0700
changeset 313 25282116ebcf
parent 229 716254ccbcc0
permissions -rw-r--r--
Eclipse 3.6 M6 support


<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="copyright" content="(C) Copyright 2009"/><meta name="DC.rights.owner" content="(C) Copyright 2009"/><meta name="DC.Type" content="concept"/><meta name="DC.Title" content="Retrieving data"/><meta name="abstract" content="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."/><meta name="description" content="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."/><meta name="DC.Relation" scheme="URI" content="GUID-AFAF423C-2193-440D-A2D3-80549FFF0A46-1AFC49140A2B"/><meta name="DC.Relation" scheme="URI" content="GUID-D54DEFE7-E878-4530-B707-A5388DFE1D9D"/><meta name="DC.Relation" scheme="URI" content="GUID-1C067AC7-2B92-4EEB-896B-814B4064590F"/><meta name="DC.Format" content="XHTML"/><meta name="DC.Identifier" content="GUID-46FA9398-10C1-429F-B496-EC70E88F9CC7"/><meta name="DC.Language" content="en"/><title>Retrieving data </title><script type="text/javascript">
      function initPage() {}
    </script><link href="../PRODUCT_PLUGIN/book.css" rel="stylesheet" type="text/css"/><link href="css/s60/style.css" rel="stylesheet" type="text/css" media="all"/></head><body onload="initPage();"><div class="body"><div class="contentLeft prTxt"><h1 class="pageHeading" id="GUID-46FA9398-10C1-429F-B496-EC70E88F9CC7">Retrieving data</h1><div><p>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.</p>
<div><h3>Fetching content from mobile devices</h3><p>You can use the <code>GetList</code> methods in the <a href="GUID-65AAF569-D347-462B-B59A-9D7CA184AB9C.html#GUID-65AAF569-D347-462B-B59A-9D7CA184AB9C">JavaScript Service API reference</a> to fetch content from mobile devices that support Web Runtime (WRT) 1.1. For more information about the content that you can fetch, see <a href="GUID-46EABDC1-37CB-412A-ACAD-1A1A9466BB68.html#GUID-46EABDC1-37CB-412A-ACAD-1A1A9466BB68">Using platform services</a>.</p><p>You can combine content from the device with content from Web sites.</p></div>
<div><h3>Fetching content from Web sites</h3><p>You can  use the following ways to fetch content from Web sites:</p><ul>
<li><p>HTTP requests</p></li>
<li><p>JavaScript Document Object Model (DOM)</p></li>
<li><p>Asynchronous JavaScript and XML (AJAX)</p></li>
</ul><p>Allow network connections from widgets in the info.plist file. For more information see, <a href="GUID-BBA0299B-81B6-4508-8D5B-5627206CBF7B.html#GUID-BBA0299B-81B6-4508-8D5B-5627206CBF7B">Creating the info.plist file</a>.</p></div>
<div><h3>Using HTTP requests</h3><p>You can use HTTP requests to retrieve data from Web services. You can use the <code>HTTP GET</code> or <code>HTTP POST</code> 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 <code>HTTP POST</code> method to retrieve data from <code>SOAP</code> services.</p><p>For an example, see <a href="GUID-1FD5C597-43B8-402E-92B8-FE0787DB4F3B.html#GUID-1FD5C597-43B8-402E-92B8-FE0787DB4F3B">Retrieving STEW data</a>.</p><div class="note"><p><strong class="note_title">Note: </strong> Set the </p><code>Expires</code> 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.</div></div>
<div><h3>Using JavaScript DOM</h3><p>Use JavaScript to manipulate content dynamically. The DOM functions include <code>document.createElement()</code> and <code>elem.appendChild()</code>.</p></div>
<div><h3>Using AJAX</h3><p>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.</p><p>AJAX uses the following:</p><ul>
<li><p>XHTML as markup language and CSS as styling information.</p></li>
<li><p>DOM accessed with a script language.</p></li>
<li><p>XMLHttpRequest object to communicate with the server asynchronously.</p></li>
<li><p>XML as the message format to transfer data.</p></li>
</ul><p>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.</p><p>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 <a href="GUID-5906D140-663D-4EE2-B0C1-4FECA5759384.html#GUID-5906D140-663D-4EE2-B0C1-4FECA5759384">STEW: managing user interaction</a></p><div class="note"><p><strong class="note_title">Note: </strong> 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.</p></div><p>For examples of using AJAX, see <a href="http://www.forum.nokia.com/info/sw.nokia.com/id/1c27d9d7-8946-4e26-947d-2b140c454876/Web_Run-Time_AccuWidget_Example.html" target="_blank">AccuWidget Example</a> and <a href="http://www.forum.nokia.com/info/sw.nokia.com/id/8dc4e8ad-b797-43f9-8dfd-318415c8bb6d/Getting_Started_with_Ajax_Overview_and_Examples.html" target="_blank">Getting Started With Ajax - Overview and Examples</a>.</p></div>
</div></div></div><div class="footer"><hr/><div class="copy">© Nokia 2009.</div></div></body></html>