add example for m.request config
This commit is contained in:
parent
b2daa1b55a
commit
3f8c630702
3 changed files with 22 additions and 0 deletions
Binary file not shown.
|
|
@ -213,6 +213,14 @@ var users = User.list();
|
|||
url: "myfile.txt",
|
||||
deserialize: function(value) {return value;}
|
||||
});</code></pre>
|
||||
<h3 id="configuring-the-underlying-xmlhttprequest">Configuring the underlying XMLHttpRequest</h3>
|
||||
<p>The <code>config</code> option can be used to arbitrarily configure the native XMLHttpRequest instance and to access properties that would not be accessible otherwise.</p>
|
||||
<p>The example below show how to configure a request where the server expects requests to have a <code>Content-Type: application/json</code> header</p>
|
||||
<pre><code class="lang-javascript">var xhrConfig = function(xhr) {
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
}
|
||||
|
||||
m.request({method: "POST", url: "/foo", config: xhrConfig});</code></pre>
|
||||
<hr>
|
||||
<h3 id="signature">Signature</h3>
|
||||
<p><a href="how-to-read-signatures.html">How to read signatures</a></p>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue