new MVC.Ajax(url, options) -> mvc.ajax
Initiates and processes an AJAX request.
{String} - the url where the request is directed
{Object} - a hash of optiosn with the following attributes:
| Option | Default | Description |
|---|---|---|
| asynchronous | true | Determines whether XMLHttpRequest is used asynchronously or not. |
| contentType | 'application/x-www-form-urlencoded' | The Content-Type header for your request. You might want to send XML instead of the regular URL-encoded format, in which case you would have to change this. |
| method | 'post' | The HTTP method to use for the request. The other widespread possibility is 'get'. |
| parameters | '' | The parameters for the request, which will be encoded into the URL for a 'get' method, or into the request body for the other methods. This can be provided either as a URL-encoded string or as any Hash-compatible object (basically anything), with properties representing parameters. |
| requestHeaders | See text | Request headers are passed as an object, with properties representing headers. |
| cache | true | true to cache template. |
Callbacks are called at various points in the life-cycle of a request, and always feature the same list of arguments. They are passed to requesters right along with their other options.
| Callback | Description |
|---|---|
| onComplete | Triggered at the very end of a request's life-cycle, once the request completed, status-specific callbacks were called, and possible automatic behaviors were processed. |
set_request_headers(user_headers) -> undefined
{Object} - headers supplied by the user in options.headers
success() -> Boolean
{Boolean} -