Module XmlHttpRequest


module XmlHttpRequest: sig .. end
XmlHttpRequest object.


type readyState =
| UNSENT
| OPENED
| HEADERS_RECEIVED
| LOADING
| DONE
class type xmlHttpRequest = object .. end
val create : unit -> xmlHttpRequest Js.t

The next part of this module allow one to use Ocaml with no need for Javascript documentation.

type http_frame = {
   code : int;
   headers : string -> string option;
   content : string;
}
The type for XHR results. The code field is the http status code of the answer. The headers field is a function associating values to any header name.
val perform_raw_url : ?headers:(string * string) list ->
?content_type:string ->
?post_args:(string * string) list ->
?get_args:(string * string) list ->
?form_arg:Form.form_contents -> string -> http_frame Lwt.t
perform_raw_url ?headers ?content_type ?post_args ?get_args ?form_arg url makes an asynchronous request to the specified url with specified options. The result is a cancelable thread returning an HTTP frame. If post_args and form_arg are None, a GET request is used. If post_args or form_arg is Some _ (even Some []) then a POST request is made.
val perform : ?headers:(string * string) list ->
?content_type:string ->
?post_args:(string * string) list ->
?get_args:(string * string) list ->
?form_arg:Form.form_contents -> Url.url -> http_frame Lwt.t
perform is the same as XmlHttpRequest.perform_raw_url except that the Url argument has type Url.url.
val get : string -> http_frame Lwt.t
get url makes an asynchronous request to the specified url