thyConnector

Class that handles raw server connections.  It handles HTTP requests to server and server responses.

It is also responsible to inform user about connection status.

Summary
Class that handles raw server connections.
Opens up a HTTP channel to target, sending data using GET or POST methods and sets up a handler to manipulate server response
Sets up the Content-type HTTP header attribute that will be sent to server when a new request is made
Cancel the request specified by ID
When creating a request, one can specify what message should be shown on the various possible states of the connection.
Specifies a location in the document where the status messages should be shown.
Sets the visibility of the messages.
Internal method used to update status messages

newRequest

p.newRequest = function (id,
target,
data,
handler,
method)

Opens up a HTTP channel to target, sending data using GET or POST methods and sets up a handler to manipulate server response

Parameters

idThe ID of the request.  This is used to avoid double calls and show the appropriate message in the appropriate place
targetThe target URL
dataThe string to be sent
handlerA function that will be called when server response arrives.  This function will be called with the response from server passed as argument.
methodHow data should be passed to server.  Valid values are ‘POST’ and ‘GET’.  Defaults to POST

setContentType

p.setContentType = function(type)

Sets up the Content-type HTTP header attribute that will be sent to server when a new request is made

Parameter

typeThe Content-type string

cancelRequest

p.cancelRequest = function (id)

Cancel the request specified by ID

Parameter

idThe request creation ID

setProgressContent

p.setProgressContent = function (id,
state,
content)

When creating a request, one can specify what message should be shown on the various possible states of the connection.  This method is used to do so.

Parameters

idThe ID of the request
stateThe state that this message should be shown
contentThe content of the message

setProgressHolder

p.setProgressHolder = function (id,
holder)

Specifies a location in the document where the status messages should be shown.

Parameters

idThe request ID
holderThe holder.  It can be a thyAPI component, a DOM element ID or a DOM element itself

setVisible

p.setVisible = function (visible)

Sets the visibility of the messages.  If true, messages are shown.  Else, messages are not shown.

Parameter

visibletrue/false

Private Methods

_setProgressState

p._setProgressState = function (id,
state)

Internal method used to update status messages

Parameters

idThe request ID
stateThe actual state of the connection
p.newRequest = function (id,
target,
data,
handler,
method)
Opens up a HTTP channel to target, sending data using GET or POST methods and sets up a handler to manipulate server response
p.setContentType = function(type)
Sets up the Content-type HTTP header attribute that will be sent to server when a new request is made
p.cancelRequest = function (id)
Cancel the request specified by ID
p.setProgressContent = function (id,
state,
content)
When creating a request, one can specify what message should be shown on the various possible states of the connection.
p.setProgressHolder = function (id,
holder)
Specifies a location in the document where the status messages should be shown.
p.setVisible = function (visible)
Sets the visibility of the messages.
p._setProgressState = function (id,
state)
Internal method used to update status messages