|
Home » Development Area » DigiGuide Listings Grabber » API Index » Class: XMLHttpRequest
Class: XMLHttpRequest
Summary
Our implementation of XMLHttpRequest. This is not related to, nor does it necessarily share features or limitations with, web browser versions.
Remarks
Our implementation of XMLHttpRequest does not currently support asynchronously downloading files.
Methods
Events
| Event | Description |
onreadystatechange |
Override this to be notified when the state of the request changes. Because we don't yet support async this is not needed. |
|
|
|
Properties
| Property | Description |
readyState |
The state of the request. | Value | Action | | 0 | uninitialized | 1 | open | 2 | sent | 3 | receiving | 4 | loaded | |
responseBody |
A string containing the response from the request. This might be binary data. |
responseText |
String containing the response from the server. This is the plain text version. |
responseXML |
String containing the response from the server. This is the XML version. Note that this returns the exact same content as responseText as we don't support XML directly. |
status |
HTTP return status of the request. |
statusText |
Text description of the status. |
|
|
|
Examples
The example below gets the DG logo from our web site but first checks to see whether the file exists and then only downloads it if it's changed since the last time we grabbed it.var client = new XMLHttpRequest();
client.open("GET", "http://www.digiguide.com/i/nav/banner_gradient.gif", false );
var mail = new File( this.dataFolder + "banner_gradient.gif" ); if( mail.exists ) { mail.open( "read", "text" ) client.setRequestHeader( "If-Modified-Since", mail.lastModified.toUTCString() ); mail.close(); }
client.send("");
if( client.status == "200" ) { var mail = new File( this.dataFolder + "banner_gradient2.gif" ); mail.open( "readWrite,replace,create", "text" ); mail.write( client.responseBody ); mail.close(); } else if( client.status == "304" ) { lp.writeLog( "Not modified since: " + client.getResponseHeader( "last-modified" ) ); } else { alert( "Failed with error " + client.status + " " + client.statusText ); return false; }
|
See Also
MultiHTTPRequest
Requirements
Build Build 1
(Last updated: October 12, 2007 16:17:17)
|
|