public class XMLHttpRequest extends EventTarget
XMLHttpRequest
.Modifier and Type | Field and Description |
---|---|
static int |
DONE
All the data has been received; the complete data is available in responseBody and responseText.
|
static int |
HEADERS_RECEIVED
The send() method has been called, but the status and headers are not yet available.
|
static int |
LOADING
Some data has been received.
|
static int |
OPENED
The object has been created, but the send() method has not been called.
|
static int |
UNSENT
The object has been created, but not initialized (the open() method has not been called).
|
Constructor and Description |
---|
XMLHttpRequest()
Creates a new instance.
|
XMLHttpRequest(boolean caseSensitiveProperties)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
abort()
Cancels the current HTTP request.
|
Object |
get(String name,
net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
Gets a named property from the object.
|
String |
getAllResponseHeaders()
Returns the labels and values of all the HTTP headers.
|
net.sourceforge.htmlunit.corejs.javascript.Function |
getOnerror()
Returns the event handler that fires on error.
|
net.sourceforge.htmlunit.corejs.javascript.Function |
getOnload()
Returns the event handler that fires on load.
|
net.sourceforge.htmlunit.corejs.javascript.Function |
getOnreadystatechange()
Returns the event handler that fires on every state change.
|
int |
getReadyState()
Returns the current state of the HTTP request.
|
String |
getResponseHeader(String headerName)
Retrieves the value of an HTTP header from the response body.
|
String |
getResponseText()
Returns a string version of the data retrieved from the server.
|
Object |
getResponseXML()
Returns a DOM-compatible document object version of the data retrieved from the server.
|
int |
getStatus()
Returns the numeric status returned by the server, such as 404 for "Not Found"
or 200 for "OK".
|
String |
getStatusText()
Returns the string message accompanying the status code, such as "Not Found" or "OK".
|
XMLHttpRequestUpload |
getUpload()
Returns the
upload property. |
XMLHttpRequestEventTarget |
getUploadIE()
Returns the
upload property - IE version. |
boolean |
getWithCredentials()
Returns the
withCredentials property. |
void |
open(String method,
Object urlParam,
Object asyncParam,
Object user,
Object password)
Assigns the destination URL, method and other optional attributes of a pending request.
|
void |
overrideMimeType(String mimeType)
Override the mime type returned by the server (if any).
|
void |
put(String name,
net.sourceforge.htmlunit.corejs.javascript.Scriptable start,
Object value) |
void |
send(Object content)
Sends the specified content to the server in an HTTP request and receives the response.
|
void |
setOnerror(net.sourceforge.htmlunit.corejs.javascript.Function errorHandler)
Sets the event handler that fires on error.
|
void |
setOnload(net.sourceforge.htmlunit.corejs.javascript.Function loadHandler)
Sets the event handler that fires on load.
|
void |
setOnreadystatechange(net.sourceforge.htmlunit.corejs.javascript.Function stateChangeHandler)
Sets the event handler that fires on every state change.
|
void |
setRequestHeader(String name,
String value)
Sets the specified header to the specified value.
|
void |
setWithCredentials(boolean withCredentials)
Sets the
withCredentials property. |
addEventListener, clearEventListenersContainer, dispatchEvent, executeEventLocally, fireEvent, getEventHandler, getEventHandlerProp, getEventListenersContainer, hasEventHandlers, removeEventListener, setEventHandler, setEventHandlerProp
clone, equivalentValues, getBrowserVersion, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, has, hasInstance, initParentScope, isReadOnlySettable, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElement
defineFunctionProperties, defineProperty, getClassName, setClassName, setParentScope
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setPrototype, size
public static final int UNSENT
public static final int OPENED
public static final int HEADERS_RECEIVED
public static final int LOADING
public static final int DONE
public XMLHttpRequest()
public XMLHttpRequest(boolean caseSensitiveProperties)
caseSensitiveProperties
- if properties and methods are case sensitivepublic net.sourceforge.htmlunit.corejs.javascript.Function getOnreadystatechange()
public void setOnreadystatechange(net.sourceforge.htmlunit.corejs.javascript.Function stateChangeHandler)
stateChangeHandler
- the event handler that fires on every state changepublic net.sourceforge.htmlunit.corejs.javascript.Function getOnload()
public void setOnload(net.sourceforge.htmlunit.corejs.javascript.Function loadHandler)
loadHandler
- the event handler that fires on loadpublic net.sourceforge.htmlunit.corejs.javascript.Function getOnerror()
public void setOnerror(net.sourceforge.htmlunit.corejs.javascript.Function errorHandler)
errorHandler
- the event handler that fires on errorpublic int getReadyState()
public String getResponseText()
public Object getResponseXML()
public int getStatus()
public String getStatusText()
public void abort()
public String getAllResponseHeaders()
public String getResponseHeader(String headerName)
headerName
- the (case-insensitive) name of the header to retrievepublic void open(String method, Object urlParam, Object asyncParam, Object user, Object password)
method
- the method to use to send the request to the server (GET, POST, etc)urlParam
- the URL to send the request toasyncParam
- Whether or not to send the request to the server asynchronously, defaults to true
user
- If authentication is needed for the specified URL, the username to use to authenticatepassword
- If authentication is needed for the specified URL, the password to use to authenticatepublic void send(Object content)
content
- the body of the message being sent with the requestpublic void setRequestHeader(String name, String value)
name
- the name of the header being setvalue
- the value of the header being setpublic void overrideMimeType(String mimeType)
mimeType
- the type used to override that returned by the server (if any)public boolean getWithCredentials()
withCredentials
property.withCredentials
propertypublic void setWithCredentials(boolean withCredentials)
withCredentials
property.withCredentials
- the withCredentials
property.public Object get(String name, net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
SimpleScriptable.getWithPreemption(String)
.
For fallback case just implement ScriptableWithFallbackGetter
.
get
in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
get
in class SimpleScriptable
public void put(String name, net.sourceforge.htmlunit.corejs.javascript.Scriptable start, Object value)
put
in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
put
in class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
public XMLHttpRequestUpload getUpload()
upload
property.upload
propertypublic XMLHttpRequestEventTarget getUploadIE()
upload
property - IE version.upload
propertyCopyright © 2002–2016 Gargoyle Software Inc.. All rights reserved.