Class Index | File Index

Classes


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
 
Field Summary
Field Attributes Field Name and Description
 
The data body of the request.
 
Sends the request asynchronously instead of blocking the browser.
 
Processes the request and response as JSON if possible.
 
The HTTP method to use.
 
Optional timeout value of the request in milliseconds.
 
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)