TODO https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequestEventTarget
Types
ProgressEvent = object of Event size*: int loaded*: int
- Source Edit
XmlHttpRequestEventTarget = object of EventTarget onloadstart*: proc (e: Event) ## Contains the function that gets called when the HTTP request first begins loading data and the loadstart event is received by this object. onprogress*: proc (e: ProgressEvent) ## Contains the function that is called periodically with information about the progress of the request and the progress event is received by this object. ontimeout*: proc (e: Event) ## Contains the function that is called if the event times out and the timeout event is received by this object; this only happens if a timeout has been previously established by setting the value of the XMLHttpRequest object's timeout attribute. onloadend*: proc (e: Event) ## Contains the function that is called when the load is completed, even if the request failed, and the loadend event is received by this object.
- The folliwing additional event handlers are inherited: onabort* :proc() Contains the function to call when a request is aborted and the abort event is received by this object. onerror* :proc() Contains the function to call when a request encounters an error and the error event is received by this object. onload* :proc() Contains the function to call when an HTTP request returns after successfully fetching content and the load event is received by this object. Source Edit
XmlHttpRequestUpload = object of XmlHttpRequestEventTarget
- Source Edit
ReadyState = enum rsUNSENT = 0, rsOPENED = 1, rsHEADERS_RECEIVED = 2, rsLOADING = 3, rsDONE = 4
- Source Edit
Procs
proc newXMLHttpRequest(): XMLHttpRequest {.
importcpp: "new XMLHttpRequest()".}- Source Edit
proc abort(r: XMLHttpRequest) {.
importcpp.}- Aborts the request if it has already been sent. Source Edit
proc getAllResponseHeaders(r: XMLHttpRequest): cstring {.
importcpp.}- Returns all the response headers, separated by CRLF, as a string, or null if no response has been received. Source Edit
proc getResponseHeader(r: XMLHttpRequest; name: cstring): cstring {.
importcpp.}- Returns the string containing the text of the specified header, or null if either the response has not yet been received or the header doesn't exist in the response. Source Edit
proc open(r: XMLHttpRequest; methd: cstring; url: cstring; async: bool = true; user: cstring = nil; password: cstring = nil) {.
importcpp.}- Initializes a request. This method is to be used from JavaScript code; to initialize a request from native code, use openRequest() instead. Source Edit
proc overrideMimeType(r: XMLHttpRequest; mime: cstring) {.
importcpp.}- Overrides the MIME type returned by the server. Source Edit
proc send(r: XMLHttpRequest) {.
importcpp.}- Source Edit
proc send[](r: XMLHttpRequest; data: cstring | Document) {.
importcpp.}- Sends the request. If the request is asynchronous (which is the default), this method returns as soon as the request is sent. Source Edit
proc setRequestHeader(r: XMLHttpRequest; header, value: cstring) {.
importcpp.}- Sets the value of an HTTP request header. You must call setRequestHeader()after open(), but before send(). Source Edit