Class Index | File Index

## Classes

- _global_
- M
- M.ActionSheetDialogView
- M.AlertDialogView
- M.Application
- M.Base64
- M.ButtonGroupView
- M.ButtonView
- M.ConfirmDialogView
- M.ContainerView
- M.Controller
- M.Cypher
- M.DataProvider
- M.Date
- M.DateValidator
- M.EmailValidator
- M.Environment
- M.EventDispatcher
- M.FormView
- M.GridView
- M.I18N
- M.ImageView
- M.LabelView
- M.ListItemView
- M.ListView
- M.LoaderView
- M.LocalStorageProvider
- M.Logger
- M.Math
- M.Model
- M.ModelAttribute
- M.ModelRegistry
- M.NotMinusValidator
- M.NumberValidator
- M.Object
- M.Observable
- M.PageView
- M.PhoneValidator
- M.PresenceValidator
- M.RecordManager
- M.RemoteStorageProvider
- M.Request
- M.ScrollView
- M.SearchBarView
- M.SelectionListItemView
- M.SelectionListView
- M.SHA256
- M.TabBarItemView
- M.TabBarView
- M.TextFieldView
- M.ToggleView
- M.ToolbarView
- M.UrlValidator
- M.Validator
- M.View
- M.ViewManager
- M.WebSqlProvider

# Class M.Request

Extends M.Object.
The root class for every request. Makes ajax requests. Is used e.g. for querying REST web services. First M.Request.init needs to be called, then send.
Defined in: request.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| M.Request()

Field Summary
Field Attributes | Field Name and Description
--- | ---
| data The data body of the request.
| isAsync Sends the request asynchronously instead of blocking the browser.
| isJSON Processes the request and response as JSON if possible.
| method The HTTP method to use.
| timeout Optional timeout value of the request in milliseconds.
| type The type of this object.
| url The URL this request is sent to.

Method Summary
Method Attributes | Method Name and Description
--- | ---
| beforeSend(request) A pre-callback that is called right before the request is sent.
| init(obj) Initializes a request.
| onError(request, msg) The callback to be called if the request failed.
| onSuccess(data, msg, request) The callback to be called if the request succeeded.
| send() Sends an Ajax request by using jQuery's $.ajax().

Methods borrowed from class M.Object:
  bindToCaller, create, destroy, extend, get, include, set

Class Detail
M.Request()
Field Detail
data
The data body of the request.

{Boolean} isAsync
Sends the request asynchronously instead of blocking the browser. You should almost always make requests asynchronous. �You can change this options with the async() helper option (or simply set it directly). Defaults to YES.

{Boolean} isJSON
Processes the request and response as JSON if possible. Defaults to NO.

{String} method
The HTTP method to use. Defaults to GET.

{Number} timeout
Optional timeout value of the request in milliseconds.

{String} type
The type of this object.

{String} url
The URL this request is sent to.
Method Detail
beforeSend(request)
A pre-callback that is called right before the request is sent.

Parameters:
{Object} request
  The XMLHttpRequest object.

init(obj)
Initializes a request. Sets the parameter of this request object with the passed values.

Parameters:
{Object} obj
  The parameter object. Includes: * method: the http method to use, e.g. 'POST' * url: the request url, e.g. 'twitter.com/search.json' (needs a proxy to be set because of Same-Origin-Policy) * isAsync: defines whether request should be made async or not. defaults to YES. Should be YES. * isJSON: defines whether to process request and response as JSON * timout: defines timeout in milliseconds * data: the data to be transmitted * beforeSend: callback that is called before request is sent * onError: callback that is called when an error occured * onSuccess: callback that is called when request was successful

onError(request, msg)
The callback to be called if the request failed.

Parameters:
{Object} request
  The XMLHttpRequest object.
{String} msg
  The error message.

onSuccess(data, msg, request)
The callback to be called if the request succeeded.

Parameters:
{String|Object} data
  The data returned from the server.
{String} msg
  A String describing the status.
{Object} request
  The XMLHttpRequest object.

send()
Sends an Ajax request by using jQuery's $.ajax(). Needs init first!

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Dec 08 2010 15:07:33 GMT+0100 (MEZ)