Class YAHOO.util.Connect

Object
   |
   +--YAHOO.util.Connect

class YAHOO.util.Connect

Field Summary [top]

boolean _isFormPost
Property modified by setForm() to determine if the transaction should be processed as a HTML form POST. 
int _polling_interval
The polling frequency, in milliseconds, for HandleReadyState. 
string _sFormData
Property modified by setForm() to the HTML form POST body. 
int _transaction_id
A transaction counter that increments the transaction id for each transaction. 

Method Summary [top]

Object abort (<object> o)
Public method to terminate a transaction, if it has not reached readyState 4. 
object asyncRequest (<string> method, <string> uri, callback, <string> postData)
Method for initiating an asynchronous request via the XHR object. 
Object createExceptionObject (<int> tId, callbackArg)
If a transaction cannot be completed due to dropped or closed connections, there may be not be enough information to build a full response object. 
Object createResponseObject (<object> o, callbackArg)
This method evaluates the server response, creates and returns the results via its properties. 
object createXhrObject (<int> transactionId)
Instantiates a XMLHttpRequest object and returns an object with two properties: the XMLHttpRequest instance and the transaction id. 
Object getConnectionObject ()
This method is called by asyncRequest and syncRequest to create a valid connection object for the transaction. 
Object handleReadyState (<object> o, callback)
This method serves as a timer that polls the XHR object's readyState property during a transaction, instead of binding a callback to the onreadystatechange event. 
Object handleTransactionResponse (<object> o, <function> callback)
This method attempts to interpret the server response and determine whether the transaction was successful, or if an error or exception was encountered. 
Object initHeader (<string> label,<string> value)
Accessor that stores the HTTP headers for each transaction. 
Object isCallInProgress (<object> o)
Accessor to check if the transaction associated with the connection object is still being processed. 
Object releaseObject (<object> o)
Dereference the XHR instance and the connection object after the transaction is completed. 
Object setForm (<string> formName)
This method assembles the form label and value pairs and constructs an encoded POST body. 
Object setHeader (<object> o)
Accessor that sets the HTTP headers for each transaction. 
Object setProgId (id)
Member to add an ActiveX id to the existing xml_progid array. 

Field Detail [top]

_isFormPost

boolean   _isFormPost
Property modified by setForm() to determine if the transaction should be processed as a HTML form POST.

_polling_interval

int   _polling_interval
The polling frequency, in milliseconds, for HandleReadyState. when attempting to determine a transaction's XHR readyState. The default is 300 milliseconds.

_sFormData

string   _sFormData
Property modified by setForm() to the HTML form POST body.

_transaction_id

int   _transaction_id
A transaction counter that increments the transaction id for each transaction.

Method Detail [top]

abort

Object abort (<object> o)
Public method to terminate a transaction, if it has not reached readyState 4.
Parameters:
o - The connection object returned by asyncRequest.
Returns:
void

asyncRequest

object asyncRequest (<string> method, <string> uri, callback, <string> postData)
Method for initiating an asynchronous request via the XHR object.
Parameters:
method - HTTP transaction method
uri - Fully qualified path of resource
callback - User-defined callback function or object
postData - POST body
callbackArg - User-defined callback arguments
Returns:
Returns the connection object

createExceptionObject

Object createExceptionObject (<int> tId, callbackArg)
If a transaction cannot be completed due to dropped or closed connections, there may be not be enough information to build a full response object. The object's property "type" value will be "failure", and two additional unique, properties are added - errorCode and errorText.
Parameters:
tId - Transaction Id
callbackArg - The user-defined arguments
errorCode - Error code associated with the exception.
errorText - Error message describing the exception.
Returns:
object

createResponseObject

Object createResponseObject (<object> o, callbackArg)
This method evaluates the server response, creates and returns the results via its properties. Success and failure cases(and exceptions) will differ in their defined properties but property "type" will confirm the transaction's status.
Parameters:
o - The connection object
callbackArg - User-defined arguments to be passed to the callback
isSuccess - Indicates whether the transaction was successful or not.
Returns:
object

createXhrObject

object createXhrObject (<int> transactionId)
Instantiates a XMLHttpRequest object and returns an object with two properties: the XMLHttpRequest instance and the transaction id.
Parameters:
transactionId - Property containing the transaction id for this transaction.
Returns:
connection object

getConnectionObject

Object getConnectionObject ()
This method is called by asyncRequest and syncRequest to create a valid connection object for the transaction. It also passes a transaction id and increments the transaction id counter.
Returns:
object

handleReadyState

Object handleReadyState (<object> o, callback)
This method serves as a timer that polls the XHR object's readyState property during a transaction, instead of binding a callback to the onreadystatechange event. Upon readyState 4, handleTransactionResponse will process the response, and the timer will be cleared.
Parameters:
o - The connection object
callback - User-defined callback object
callbackArg - User-defined arguments passed to the callback
Returns:
void

handleTransactionResponse

Object handleTransactionResponse (<object> o, <function> callback)
This method attempts to interpret the server response and determine whether the transaction was successful, or if an error or exception was encountered.
Parameters:
o - The connection object
callback - - User-defined callback object
callbackArg - - User-defined arguments to be passed to the callback
Returns:
void

initHeader

Object initHeader (<string> label,<string> value)
Accessor that stores the HTTP headers for each transaction.
Parameters:
label - The HTTP header label
value - The HTTP header value
Returns:
void

isCallInProgress

Object isCallInProgress (<object> o)
Accessor to check if the transaction associated with the connection object is still being processed.
Parameters:
o - The connection object returned by asyncRequest
Returns:
boolean

releaseObject

Object releaseObject (<object> o)
Dereference the XHR instance and the connection object after the transaction is completed.
Parameters:
o - The connection object
Returns:
void

setForm

Object setForm (<string> formName)
This method assembles the form label and value pairs and constructs an encoded POST body. Both syncRequest() and asyncRequest() will automatically initialize the transaction with a HTTP header Content-Type of application/x-www-form-urlencoded.
Parameters:
formName - value of form name attribute
Returns:
void

setHeader

Object setHeader (<object> o)
Accessor that sets the HTTP headers for each transaction.
Parameters:
o - The connection object for the transaction.
Returns:
void

setProgId

Object setProgId (id)
Member to add an ActiveX id to the existing xml_progid array. In the event(unlikely) a new ActiveX id is introduced, it can be added without internal code modifications.
Parameters:
string - id The ActiveX id to be added to initialize the XHR object.
Returns:
void