Class SweetDevRia.Ajax
Ajax utility class
Defined in: Ajax.js.
Constructor Attributes | Constructor Name and Description |
---|---|
<private> |
SweetDevRia.Ajax(id)
|
Field Attributes | Field Name and Description |
---|---|
<private> <static> |
SweetDevRia.Ajax.SYNCHRO_CALL
Constant defining the synchronization state to send as param
|
On construit un objet XmlHttpRequest
|
Method Attributes | Method Name and Description |
---|---|
<private> |
Generic callback
Call onServerUnreachable() on server error.
|
get(request, synchroCall, prepare)
Send a GET Ajax request
|
|
Get the callback function
|
|
<private> <static> |
SweetDevRia.Ajax.getInstance(id)
Get an Ajax instance from its id
|
Get the state of the request
|
|
Get the text request's response
|
|
Get the XML request's response
|
|
Return the status of the request
|
|
<static> |
SweetDevRia.Ajax.onReceiveResponse()
Override this function to trigger an action just after an ajax response is received.
|
<static> |
SweetDevRia.Ajax.onSendRequest()
Override this function to trigger an action just before an ajax request is sent.
|
onServerUnreachable(ex, errorCode)
Function called if the server cannot be reached
|
|
onSessionTimeout(message)
Function called if the user's server session has timeouted or is not valid anymore
|
|
post(request, parameters, synchroCall, prepare)
Send a POST Ajax request
|
|
<private> <static> |
SweetDevRia.Ajax.prepareParams(map, prepare)
Convert a parameterMap to a String to be send by Ajax
|
reset()
Reinitialize the Ajax object
|
|
<private> |
send(method, url, param, asynchroCall, prepare)
Send an Ajax request
|
setCallback(callback)
Set the function to call when response is coming back
|
|
setRequestHeader(field, field)
Add a header field to the Ajax object requester
|
Field Detail
<private> <static>
{String}
SweetDevRia.Ajax.SYNCHRO_CALL
Constant defining the synchronization state to send as param
xmlhttp
On construit un objet XmlHttpRequest
Method Detail
<private>
bindCallback()
Generic callback
Call onServerUnreachable() on server error.
get(request, synchroCall, prepare)
Send a GET Ajax request
- Parameters:
- {String} request
- URL
- {boolean} synchroCall
- True for a synchrone server call, else false
- {formMode} prepare
- parameter for a formular not JSON Communication
{Function}
getCallback()
Get the callback function
- Returns:
- {Function} callback function
<private> <static>
{Ajax}
SweetDevRia.Ajax.getInstance(id)
Get an Ajax instance from its id
- Parameters:
- {String} id
- the instance id to get
- Returns:
- an Ajax instance according to the required id
{int}
getReadyState()
Get the state of the request
- Returns:
- {int} ready state
{String}
getResponseText()
Get the text request's response
- Returns:
- the response text for this Ajax object
{String}
getResponseXML()
Get the XML request's response
- Returns:
- the response XML for this Ajax object
{int}
getStatus()
Return the status of the request
- Returns:
- the status of the request
<static>
SweetDevRia.Ajax.onReceiveResponse()
Override this function to trigger an action just after an ajax response is received. To be overridden.
<static>
SweetDevRia.Ajax.onSendRequest()
Override this function to trigger an action just before an ajax request is sent. To be overridden.
onServerUnreachable(ex, errorCode)
Function called if the server cannot be reached
- Parameters:
- {Exception} ex
- the JavaScript native exception caught (Firefox)
- {int} errorCode
- the error code (Internet Explorer)
- See:
- http://groups.google.com/group/prototype-core/msg/3e0fe68dd1da9c1e
onSessionTimeout(message)
Function called if the user's server session has timeouted or is not valid anymore
- Parameters:
- {String} message
- the message sent by the server. This message is formatted as an HTML one, displaying a 401 http error. Displayable into an alert or window.
post(request, parameters, synchroCall, prepare)
Send a POST Ajax request
- Parameters:
- {String} request
- URL
- {String} parameters
- to send to request (will be concatenated to URL)
- {boolean} synchroCall
- True for a synchrone server call, else false
- {formMode} prepare
- parameter for a formular not JSON Communication
<private> <static>
{String}
SweetDevRia.Ajax.prepareParams(map, prepare)
Convert a parameterMap to a String to be send by Ajax
- Parameters:
- {Map} map
- the parameter map to convert to string
- {formMode} prepare
- parameter for a formular not JSON Communication
- Returns:
- the parameter string corresponding to the map
reset()
Reinitialize the Ajax object
<private>
send(method, url, param, asynchroCall, prepare)
Send an Ajax request
- Parameters:
- {String} method
- "POST" or "GET" method
- {String} url
- the url to call
- {Array} param
- the parameters to send to request (will be concatenated to URL)
- {boolean} asynchroCall
- whether the call must be asynchrone (true) or synchrone (false). default : true.
- {formMode} prepare
- parameter for a formular not JSON Communication
setCallback(callback)
Set the function to call when response is coming back
- Parameters:
- {Function} callback
- JavaScript function to execute when response is coming back
setRequestHeader(field, field)
Add a header field to the Ajax object requester
- Parameters:
- {String} field
- name
- {String} field
- value