diff --git a/archive/v0.1.4/mithril.min.zip b/archive/v0.1.4/mithril.min.zip index 3dede029..74333ec8 100644 Binary files a/archive/v0.1.4/mithril.min.zip and b/archive/v0.1.4/mithril.min.zip differ diff --git a/archive/v0.1.4/mithril.request.html b/archive/v0.1.4/mithril.request.html index 728c8f68..eeeb33ed 100644 --- a/archive/v0.1.4/mithril.request.html +++ b/archive/v0.1.4/mithril.request.html @@ -213,6 +213,14 @@ var users = User.list(); url: "myfile.txt", deserialize: function(value) {return value;} }); +

Configuring the underlying XMLHttpRequest

+

The config option can be used to arbitrarily configure the native XMLHttpRequest instance and to access properties that would not be accessible otherwise.

+

The example below show how to configure a request where the server expects requests to have a Content-Type: application/json header

+
var xhrConfig = function(xhr) {
+    xhr.setRequestHeader("Content-Type", "application/json");
+}
+
+m.request({method: "POST", url: "/foo", config: xhrConfig});

Signature

How to read signatures

diff --git a/docs/mithril.request.md b/docs/mithril.request.md index 7cdfee61..27cac116 100644 --- a/docs/mithril.request.md +++ b/docs/mithril.request.md @@ -226,6 +226,20 @@ var file = m.request({ }); ``` +### Configuring the underlying XMLHttpRequest + +The `config` option can be used to arbitrarily configure the native XMLHttpRequest instance and to access properties that would not be accessible otherwise. + +The example below show how to configure a request where the server expects requests to have a `Content-Type: application/json` header + +```javascript +var xhrConfig = function(xhr) { + xhr.setRequestHeader("Content-Type", "application/json"); +} + +m.request({method: "POST", url: "/foo", config: xhrConfig}); +``` + --- ### Signature