<XMLHttpRequest>
An implementation of XMLHttpRequest (also called "AJAX") for compatibility in SWF runtimes

JavaScript: lz.XMLHttpRequest
extends <node> » lz.Eventable »

This class implements the XMLHTTPRequest as specified by the WHATWG consortium.

In SOLO deployed applications, this class departs from the specification in these ways:

  • Cannot set HTTP headers
  • Cannot access response headers
  • Cannot send raw POST data
  • Cannot send repeated query args in a POST using LoadVars
  • Username/password Auth args to send() not supported
    <script>
        function loadXMLDoc(url) {
            var req = new lz.XMLHttpRequest();
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.setRequestHeader('X-Test', 'one');
            req.setRequestHeader('X-Test', 'two');
            req.send(null);
        }
        
        function processReqChange(request) {
            Debug.debug("processReqChange: req.readyState %w", request.readyState);
            // only if request shows "loaded"
            if (request.readyState == 4) {
            // only if "OK"
        if (request.status == 200) {
            Debug.debug("arg = %w", request);
            Debug.debug("request.status: %w", request.status);
            Debug.debug("request.responseText: %w", request.responseText);
            Debug.debug("request.responseXML %w:", request.responseXML);
            Debug.debug("request.getAllResponseaders:",
            request.getAllResponseHeaders());
        } else {
            Debug.debug("There was a problem retrieving the XML data: %w\n",
            request.statusText);
               }
           }
        }
    </script>
                

Attributes

Name (CSS property) Type (tag) Type (js) Default Category
headers expression any null read/write
   
onreadystatechange expression any null read/write
   
parsexml expression any true read/write
   
proxied expression any canvas.proxied read/write
   
readyState number Number 0 read/write
  Object status integer: 0 Uninitialised The initial value. 1 Open The open() method has been successfully called. 2 Sent The send() method has been successfully called, but no data has yet been received. 3 Receiving Data is being received, but the data transfer is not yet complete. 4 Loaded The data transfer has been completed.
responseText string String   read/write
  String version of data returned from server process
responseXML expression any   read/write
  DOM-compatible document object of data returned from server process
status number Number 0 read/write
  Numeric code returned by server, such as 404 for "Not Found" or 200 for "OK"
statusText string String   read/write
  String message accompanying the status code
timeout expression any 60000 read/write
   

Methods

abort()
XMLHttpRequest.abort();
Stops the current request

getAllResponseHeader()
XMLHttpRequest.getAllResponseHeader(hname:String);
Returns the string value of a single header label
Parameter Name Type Description
hname:String    

getAllResponseHeaders()
XMLHttpRequest.getAllResponseHeaders();
Returns complete set of headers (labels and values) as an LzParam

getResponseHeader()
XMLHttpRequest.getResponseHeader(hname:String);
Returns the string value of a single header label
Parameter Name Type Description
hname:String    

handleResponse()
XMLHttpRequest.handleResponse(dreq);
Parameter Name Type Description
dreq    

ondataHandler()
XMLHttpRequest.ondataHandler();

onerrorHandler()
XMLHttpRequest.onerrorHandler();

open()
XMLHttpRequest.open(method:String!, url:String!, async:Boolean, uname:String, password:String);
Assigns destination URL, method, and other optional attributes of a pending request
Parameter Name Type Description
method:String!    
url:String!    
async:Boolean    
uname:String    
password:String    

send()
XMLHttpRequest.send(content:*);
Transmits the request, optionally with postable string or DOM object data

In serverless mode, there's no Flash API to post a raw data string in the POST body.

Doesn't support "content" arg yet for serverless operation

Parameter Name Type Description
content:*    

setRequestHeader()
XMLHttpRequest.setRequestHeader(key:String, val:String);
Assigns a label/value pair to the header to be sent with a request
Parameter Name Type Description
key:String    
val:String    

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Events inherited from <node>

onconstruct, ondata, oninit

Events inherited from lz.Eventable

ondestroy