Source code

CERNY.http.Request

This script provides Ajax functionality to send HTTP requests to a server.

Used by

None

Functions

Request

This class represents the HTTP request. This is a wrapper to add some convenience and avoid the word XML.

method (string) : the method of the request
url (string) : the URL of the request
return (object) : an instance of this class
sendAsynch

Send this request asynchronously. The browser will continue to execute the script without waiting for the response.

The parameter callback is an object that may contain a function for each phases of the request. The name of the property is the number of the phase, so UNSET is "0", OPEN is "1", SENT is "2", LOADING is "3" and DONE is "4". If a function is passed instead of an object, it is interpreted as a callback when the request is done (complete, the response has arrived, a status is available).

callback (function,object) : handler(s) for the request processing phases
sendSynch

Send this request synchronously. The browser will wait for the response with further execution.

return (CERNY.http.Response) : the response of the server
setBody

Set the body of the request, optionally pass the content type of the body. It is recommended to pass the content type.

body (string) : the body the request should transport
contentType (undefined,string) : the content type of the body
setHeader

Set a header of the request.

name (string) : the name of the header
value (string) : the value of the header

History

2007-12-08 : Split into two scripts, Request and Response.
2007-07-07 : Fixed bug caused by json.js when setting request headers.
2007-06-18 : Created.

API Documentation for version

2.0

Scripts

Scripts

Request Response

2.0

Functions