the compact javascript framework
in partnership with mediatemple
Basic XMLHttpRequest Wrapper.
| options | an object with options names as keys. See options below. |
| method | ’post’ or ‘get’ - the protocol for the request; optional, defaults to ‘post’. |
| async | boolean: asynchronous option; true uses asynchronous requests. Defaults to true. |
| encoding | the encoding, defaults to utf-8. |
| autoCancel | cancels the already running request if another one is sent. defaults to false. |
| headers | accepts an object, that will be set to request headers. |
| onRequest | function to execute when the XHR request is fired. |
| onSuccess | function to execute when the XHR request completes. |
| onStateChange | function to execute when the state of the XMLHttpRequest changes. |
| onFailure | function to execute when the state of the XMLHttpRequest changes. |
| running | true if the request is running. |
| response | object, text and xml as keys. You can access this property in the onSuccess event. |
var myXHR = new XHR({method: 'get'}).send('http://site.com/requestHandler.php', 'id=john&lastid=dorian');
| Properties | |
| setHeader | Add/modify an header for the request. |
| send | Opens the XHR connection and sends the data. |
| cancel | Cancels the running request. |
Add/modify an header for the request. It will not override headers from the options.
var myXhr = new XHR(url, {method: 'get', headers: {'X-Request': 'JSON'}}); myXhr.setHeader('Last-Modified','Sat, 1 Jan 2005 05:00:00 GMT');
Documentation by Aaron Newton & Mootools Developers, generated by NaturalDocs and GeSHi