Class YAHOO.util.Connect

Object
   |
   +--YAHOO.util.Connect

class YAHOO.util.Connect

Field Summary [top]

boolean _has_http_headers
Determines if HTTP headers are set. 
object _http_header
Object of HTTP header(s) 
boolean _isFormSubmit
Property modified by setForm() to determine if the data should be submitted as an HTML form. 
array _msxml_progid
Array of MSFT ActiveX ids for XMLHttpRequest. 
array _poll
Collection of polling references to the polling mechanism in handleReadyState. 
int _polling_interval
The polling frequency, in milliseconds, for HandleReadyState. 
string _sFormData
Property modified by setForm() to set the HTML form data for each transaction. 
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, <object> 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, <object> 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 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)
Public method that stores the custom HTTP headers for each transaction. 
Object isCallInProgress (<object> o)
Public method to check if the transaction is still being processed. 
Object releaseObject (<object> o)
Dereference the XHR instance and the connection object after the transaction is completed. 
Object setForm (formId)
This method assembles the form label and value pairs and constructs an encoded string. 
Object setHeader (<object> o)
Accessor that sets the HTTP headers for each transaction. 
Object setPollingInterval (<int> i)
Member to modify the default polling interval. 
Object setProgId (id)
Member to add an ActiveX id to the existing xml_progid array. 

Field Detail [top]

_has_http_headers

boolean   _has_http_headers
Determines if HTTP headers are set.

_http_header

object   _http_header
Object of HTTP header(s)

_isFormSubmit

boolean   _isFormSubmit
Property modified by setForm() to determine if the data should be submitted as an HTML form.

_msxml_progid

array   _msxml_progid
Array of MSFT ActiveX ids for XMLHttpRequest.

_poll

array   _poll
Collection of polling references to the polling mechanism in handleReadyState.

_polling_interval

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

_sFormData

string   _sFormData
Property modified by setForm() to set the HTML form data for each transaction.

_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, <object> 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
Returns:
Returns the connection object

createExceptionObject

Object createExceptionObject (<int> tId, <object> 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 failure callback will be fired and this specific condition can be identified by a status property value of 0.
Parameters:
tId - Transaction Id
callbackArg - User-defined argument or arguments to be passed to the callback.
Returns:
object

createResponseObject

Object createResponseObject (<object> o, <object> callbackArg)
This method evaluates the server response, creates and returns the results via its properties. Success and failure cases will differ in the response object's property values.
Parameters:
o - The connection object
callbackArg - User-defined argument or arguments to be passed to the callback
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 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, <object> 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
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
Returns:
void

initHeader

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

isCallInProgress

Object isCallInProgress (<object> o)
Public method to check if the transaction 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 (formId)
This method assembles the form label and value pairs and constructs an encoded string. asyncRequest() will automatically initialize the transaction with a HTTP header Content-Type of application/x-www-form-urlencoded.
Parameters:
string - || object} form id or name attribute, or form object.
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

setPollingInterval

Object setPollingInterval (<int> i)
Member to modify the default polling interval.
Parameters:
i - The polling interval in milliseconds.
Returns:
void

setProgId

Object setProgId (id)
Member to add an ActiveX id to the existing xml_progid array. In the event 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