AJAX Ajax.Response is a object passed as first argument of all AJAX request callbacks.
It is a wrapper around a native xmlHttpRequest object.It normalizes all cross-browser issues while adding support for JSON via responseJSON and headerJSON properties.
Properties of Ajax.Response Object :
. Status.
. StatusText.
. readyState.
. ResponseXML.
. ResponseJSON.
. headerJSON.
. request.
. transport.
Here is an Example to Display usage of status and responseText properties in AJAX:
<script>
function SubmitRequest(){
new AJax.Request('/cgi-bin/ajax.cgi',
{
method:'get',
onsuccess:successFunc,
onFailure: failureFumc
});
}
function successFunc(response) {
if(100 == response.status) {
alert("call has been done")
}
var container = $('notice');
var content = response.responseText;
container.update(content);
}
function failureFunc(response)
{
alert("call has not done");
}
<
/script
>
Methods of Ajax.Response object :
. getHeader(name) --> This Method Returns the Header value if present otherwise it returns null value.
. getAllHeaders() -->This method Returns a string containing all headers separated by a line break.
. getResponseHeader() -->This method Returns the value of the requested header if present.
. getAllResponseHeaders() -->This method Returns a string containing all headers separated by a line break.