Class AjxRpc
This static class provides an interface for send requests to a server. It
essentially wraps AjxRpcRequest. This AjxRpc link maintains a cache of
AjxRpcRequest objects which it attempts to reuse before allocating additional
objects. It also has a mechanism whereby if an AjxRpcRequest object is
in a "busy" state for a extended period of time, it will reap it appropriately.
Defined in: AjxRpc.js.
Class Summary
Constructor Attributes |
Constructor Name and Description |
|
|
Method Summary
Method Attributes |
Method Name and Description |
<static> |
AjxRpc. invoke(requestStr, serverUrl, requestHeaders, callback, method, timeout)
Submits a request to a URL.
|
Class Detail
AjxRpc()
Author: Ross Dargahi, Conrad Damon.
- See:
- AjxRpcRequest
Method Detail
<static>
{object|hash}
AjxRpc.invoke(requestStr, serverUrl, requestHeaders, callback, method, timeout)
Submits a request to a URL. The request is handled through a pool of request
contexts (each a wrapped XmlHttpRequest). The context does the real work.
- Parameters:
-
{string} requestStr
Optional
- the HTTP request string/document
-
{string} serverUrl
- the request target
-
{array} requestHeaders
Optional
- an array of HTTP request headers
-
{AjxCallback} callback
- the callback for asynchronous requests. This callback
will be invoked when the requests completes. It will be passed the same
values as when this method is invoked synchronously (see the return values
below) with the exception that if the call times out (see timeout param
below), then the object passed to the callback will be the same as in the
error case with the exception that the status will be set to
AjxRpcRequest.TIMEDOUT.
-
{Constant} method
Optional
- the HTTP method -- GET, POST, PUT, DELETE. if
true , use get method for backward compatibility
-
{number} timeout
Optional
- the timeout (in milliseconds) after which the request is canceled
- Throws:
-
{AjxException.NETWORK_ERROR}
- a network error occurs
-
{AjxException.UNKNOWN_ERROR}
- an unknown error occurs
- Returns:
- {object|hash} if invoking in asynchronous mode, then it will return the id of the
underlying AjxRpcRequest object. Else if invoked synchronously, if
there is no error (i.e. we get a HTTP result code of 200 from the server),
an object with the following attributes is returned
- text - the string response text
- xml - the string response xml
- success - boolean set to true
If there is an error, then the following will be returned
- text - the string response text
-
- xml - the string response xml
- success - boolean set to
false
- status - HTTP status
- See:
- AjxRpcRequest#invoke
|