com.gargoylesoftware.htmlunit.javascript.host
Class XMLHttpRequest

java.lang.Object
  extended by org.mozilla.javascript.ScriptableObject
      extended by com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
          extended by com.gargoylesoftware.htmlunit.javascript.host.XMLHttpRequest
All Implemented Interfaces:
java.io.Serializable, org.mozilla.javascript.ConstProperties, org.mozilla.javascript.debug.DebuggableObject, org.mozilla.javascript.Scriptable

public class XMLHttpRequest
extends SimpleScriptable

A JavaScript object for a XMLHttpRequest.

Version:
$Revision: 1.3 $
Author:
Daniel Gredler, Marc Guillemot
See Also:
Safari documentation, Serialized Form

Field Summary
static int STATE_COMPLETED
 All the data has been received; the complete data is available in responseBody and responseText.
static int STATE_INTERACTIVE
 Some data has been received.
static int STATE_LOADED
 The send() method has been called, but the status and headers are not yet available.
static int STATE_LOADING
 The object has been created, but the send() method has not been called.
static int STATE_UNINITIALIZED
 The object has been created, but not initialized (the open() method has not been called).
 
Fields inherited from class org.mozilla.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
XMLHttpRequest()
 Creates a new instance.
 
Method Summary
 void jsConstructor()
 Javascript constructor.
 void jsxFunction_abort()
 Cancels the current HTTP request.
 java.lang.String jsxFunction_getAllResponseHeaders()
 Returns the labels and values of all the HTTP headers.
 java.lang.String jsxFunction_getResponseHeader(java.lang.String headerName)
 Retrieves the value of an HTTP header from the response body.
 void jsxFunction_open(java.lang.String method, java.lang.String url, boolean async, java.lang.String user, java.lang.String password)
 Assigns the destination URL, method and other optional attributes of a pending request.
 void jsxFunction_overrideMimeType(java.lang.String mimeType)
 Override the mime type returned by the server (if any).
 void jsxFunction_send(java.lang.Object content)
 Sends the specified content to the server in an HTTP request and receives the response.
 void jsxFunction_setRequestHeader(java.lang.String name, java.lang.String value)
 Sets the specified header to the specified value.
 org.mozilla.javascript.Function jsxGet_onreadystatechange()
 Returns the event handler that fires on every state change.
 int jsxGet_readyState()
 Returns the current state of the HTTP request.
 java.lang.String jsxGet_responseText()
 Returns a string version of the data retrieved from the server.
 java.lang.Object jsxGet_responseXML()
 Returns a DOM-compatible document object version of the data retrieved from the server.
 int jsxGet_status()
 Returns the numeric status returned by the server, such as 404 for "Not Found" or 200 for "OK".
 java.lang.String jsxGet_statusText()
 Returns the string message accompanying the status code, such as "Not Found" or "OK".
 void jsxSet_onreadystatechange(org.mozilla.javascript.Function stateChangeHandler)
 Sets the event handler that fires on every state change.
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
get, getBooleanArg, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getHtmlElementOrDie, getHtmlElementOrNull, getIntArg, getObjectArg, getStringArg, makeScriptableFor, setDomNode, setHtmlElement
 
Methods inherited from class org.mozilla.javascript.ScriptableObject
associateValue, avoidObjectDetection, callMethod, callMethod, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, get, getAllIds, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, has, has, hasInstance, hasProperty, hasProperty, isConst, isSealed, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_COMPLETED

public static final int STATE_COMPLETED
All the data has been received; the complete data is available in responseBody and responseText.

See Also:
Constant Field Values

STATE_INTERACTIVE

public static final int STATE_INTERACTIVE
Some data has been received.

See Also:
Constant Field Values

STATE_LOADED

public static final int STATE_LOADED
The send() method has been called, but the status and headers are not yet available.

See Also:
Constant Field Values

STATE_LOADING

public static final int STATE_LOADING
The object has been created, but the send() method has not been called.

See Also:
Constant Field Values

STATE_UNINITIALIZED

public static final int STATE_UNINITIALIZED
The object has been created, but not initialized (the open() method has not been called).

See Also:
Constant Field Values
Constructor Detail

XMLHttpRequest

public XMLHttpRequest()
Creates a new instance. JavaScript objects must have a default constructor.

Method Detail

jsConstructor

public void jsConstructor()
Javascript constructor.


jsxFunction_abort

public void jsxFunction_abort()
Cancels the current HTTP request.


jsxFunction_getAllResponseHeaders

public java.lang.String jsxFunction_getAllResponseHeaders()
Returns the labels and values of all the HTTP headers.

Returns:
The labels and values of all the HTTP headers.

jsxFunction_getResponseHeader

public java.lang.String jsxFunction_getResponseHeader(java.lang.String headerName)
Retrieves the value of an HTTP header from the response body.

Parameters:
headerName - The (case-insensitive) name of the header to retrieve.
Returns:
The value of the specified HTTP header.

jsxFunction_open

public void jsxFunction_open(java.lang.String method,
                             java.lang.String url,
                             boolean async,
                             java.lang.String user,
                             java.lang.String password)
Assigns the destination URL, method and other optional attributes of a pending request.

Parameters:
method - The method to use to send the request to the server (GET, POST, etc).
url - The url to send the request to.
async - Whether or not to send the request to the server asynchronously.
user - If authentication is needed for the specified URL, the username to use to authenticate.
password - If authentication is needed for the specified URL, the password to use to authenticate.

jsxFunction_overrideMimeType

public void jsxFunction_overrideMimeType(java.lang.String mimeType)
Override the mime type returned by the server (if any). This may be used, for example, to force a stream to be treated and parsed as text/xml, even if the server does not report it as such. This must be done before the send method is invoked.

Parameters:
mimeType - the type used to override that returned by the server (if any)
See Also:
XUL Planet

jsxFunction_send

public void jsxFunction_send(java.lang.Object content)
Sends the specified content to the server in an HTTP request and receives the response.

Parameters:
content - The body of the message being sent with the request.

jsxFunction_setRequestHeader

public void jsxFunction_setRequestHeader(java.lang.String name,
                                         java.lang.String value)
Sets the specified header to the specified value. The open method must be called before this method, or an error will occur.

Parameters:
name - The name of the header being set.
value - The value of the header being set.

jsxGet_onreadystatechange

public org.mozilla.javascript.Function jsxGet_onreadystatechange()
Returns the event handler that fires on every state change.

Returns:
The event handler that fires on every state change.

jsxGet_readyState

public int jsxGet_readyState()
Returns the current state of the HTTP request. The possible values are:

Returns:
The current state of the HTTP request.

jsxGet_responseText

public java.lang.String jsxGet_responseText()
Returns a string version of the data retrieved from the server.

Returns:
A string version of the data retrieved from the server.

jsxGet_responseXML

public java.lang.Object jsxGet_responseXML()
Returns a DOM-compatible document object version of the data retrieved from the server.

Returns:
A DOM-compatible document object version of the data retrieved from the server.

jsxGet_status

public int jsxGet_status()
Returns the numeric status returned by the server, such as 404 for "Not Found" or 200 for "OK".

Returns:
The numeric status returned by the server.

jsxGet_statusText

public java.lang.String jsxGet_statusText()
Returns the string message accompanying the status code, such as "Not Found" or "OK".

Returns:
The string message accompanying the status code.

jsxSet_onreadystatechange

public void jsxSet_onreadystatechange(org.mozilla.javascript.Function stateChangeHandler)
Sets the event handler that fires on every state change.

Parameters:
stateChangeHandler - The event handler that fires on every state change.


Copyright © 2003-2016 AppPerfect Corporation. All Rights Reserved.