add example for m.request config

This commit is contained in:
Leo Horie 2014-04-08 15:33:54 -04:00
parent b2daa1b55a
commit 3f8c630702
3 changed files with 22 additions and 0 deletions

View file

@ -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