pub struct XmlHttpRequest(/* private fields */);
Expand description
Use XmlHttpRequest (XHR) objects to interact with servers. You can retrieve data from a URL without having to do a full page refresh. This enables a Web page to update just part of a page without disrupting what the user is doing. XmlHttpRequest is used heavily in Ajax programming.
Implementations§
Source§impl XmlHttpRequest
impl XmlHttpRequest
Sourcepub fn new() -> XmlHttpRequest
pub fn new() -> XmlHttpRequest
Creates new XmlHttpRequest
.
Sourcepub fn ready_state(&self) -> XhrReadyState
pub fn ready_state(&self) -> XhrReadyState
Returns the current state of the request as a XhrReadyState.
Sourcepub fn response_type(&self) -> XhrResponseType
pub fn response_type(&self) -> XhrResponseType
Returns the type of the request as a XhrResponseType
Sourcepub fn set_response_type(
&self,
kind: XhrResponseType,
) -> Result<(), XhrSetResponseTypeError>
pub fn set_response_type( &self, kind: XhrResponseType, ) -> Result<(), XhrSetResponseTypeError>
Set the type that the XmlHttpRequest should return
Sourcepub fn response_text(&self) -> Result<Option<String>, TODO>
pub fn response_text(&self) -> Result<Option<String>, TODO>
Returns a string that contains the response to the request as text, or None if the request was unsuccessful or has not yet been sent.
Sourcepub fn raw_response(&self) -> Value
pub fn raw_response(&self) -> Value
Returns the object representing the response
Sourcepub fn status(&self) -> u16
pub fn status(&self) -> u16
Returns an unsigned short with the status of the response of the request.
Sourcepub fn open(&self, method: &str, url: &str) -> Result<(), TODO>
pub fn open(&self, method: &str, url: &str) -> Result<(), TODO>
Open connection with given method (ie GET or POST), and the url to hit.
Sourcepub fn get_response_header(&self, header: &str) -> Option<String>
pub fn get_response_header(&self, header: &str) -> Option<String>
Returns the string containing the text of the specified header. If there are multiple response headers with the same name, then their values are returned as a single concatenated string.
Sourcepub fn set_request_header(&self, header: &str, value: &str) -> Result<(), TODO>
pub fn set_request_header(&self, header: &str, value: &str) -> Result<(), TODO>
Sets the value of an HTTP request header. Must be called after open()
,
but before send()
. If this method is called several times with the same
header, the values are merged into one single request header.
Sourcepub fn send_with_string(&self, body: &str) -> Result<(), TODO>
pub fn send_with_string(&self, body: &str) -> Result<(), TODO>
Send request on an open connection with string body
Sourcepub fn send_with_bytes(&self, body: &[u8]) -> Result<(), TODO>
pub fn send_with_bytes(&self, body: &[u8]) -> Result<(), TODO>
Send request on an open connection with a byte array body
Trait Implementations§
Source§impl AsRef<Reference> for XmlHttpRequest
impl AsRef<Reference> for XmlHttpRequest
Source§impl Clone for XmlHttpRequest
impl Clone for XmlHttpRequest
Source§fn clone(&self) -> XmlHttpRequest
fn clone(&self) -> XmlHttpRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for XmlHttpRequest
impl Debug for XmlHttpRequest
Source§impl From<XmlHttpRequest> for EventTarget
impl From<XmlHttpRequest> for EventTarget
Source§fn from(value: XmlHttpRequest) -> Self
fn from(value: XmlHttpRequest) -> Self
Source§impl From<XmlHttpRequest> for Reference
impl From<XmlHttpRequest> for Reference
Source§fn from(value: XmlHttpRequest) -> Self
fn from(value: XmlHttpRequest) -> Self
Source§impl IEventTarget for XmlHttpRequest
impl IEventTarget for XmlHttpRequest
Source§fn add_event_listener<T, F>(&self, listener: F) -> EventListenerHandlewhere
T: ConcreteEvent,
F: FnMut(T) + 'static,
fn add_event_listener<T, F>(&self, listener: F) -> EventListenerHandlewhere
T: ConcreteEvent,
F: FnMut(T) + 'static,
EventTarget
on which it’s called. Read more