Whitebeam Object Definition

Site Map
 
Home
 
Application Guide
Reference
  Installation
  Configuration
  XML Markup
  JavaScript Classes
  ROM
  Templates
  Environment
  Dev Process
  Tools
  External Links
  Example libraries
Community
Contact Whitebeam
To-Do
Download
Credits
Licence
Whitebeam Users
 
 
 

Whitebeam Object Definition

Method Description

HttpRequest.doRequest()

Send a request to a remote HTTP server.

Syntax

number = HttpRequest.doRequest()

Parameters

The 'HttpRequest.doRequest' method takes no parameters

Results

The 'HttpRequest.doRequest' method returns number:

Type/Value Range/Length Description
number   HTTP result code returned from the remote server, or -1 if the server could not be contacted.

Remarks

This methods creates an HTTP request and sends the message to a remote server. The request makes used of use of the properties set on the object before calling this method.

Example

The following simple example reads the contents of the Whitebeam homepage (www.whitebeam.org) and extracts all the anchor tags with 'href' attributes. These links are then formatted into a simple HTML table.


 var request = new HttpRequest;

  request.url="http://www.whitebeam.org";
  request.method="GET";

  request.doRequest();
  if (request.res==200) {
     // Create a parser.
     var aParser = new XmlParser(rb.xml);

     // Build the tree.
     if (aParser.build(request.body)) {

       // Find all the anchor tags with href attributes using XPath.
       var bodyTag = aParser.root.select("//a[@href]");

       // Display all the links we find.
       for (var i=0;i<bodyTag.length;i++) {
          // Write to the client.
          rb.page.write(">tr><td>"+bodyTag[i].execute().text()+"</td></tr>\n");
       }
     }
     else {
       rb.page.write("Couldn't build XML Tree - text contains errors!");
     }
  }
               

A separate XML tutorial explains how to use the XML features of Whitebeam

Whitebeam release 1.3.36
(loadtime : 22ms)