AJAX - The Complete Reference

(avery) #1

PART II


Chapter 5: Developing an Ajax Library 197


Methods Description Example
AjaxTCR.comm
.abortRequest(requestObj)

Aborts the
XHR request
of the given
request object.

AjaxTCR.comm.abortRequest(request)

AjaxTCR.comm.sendRequest(url,
options)

Primar y
method that
is called to
send the
request.
Requires
a string
for a URL
parameter
and an object
of options as
specified in
Table 5-3.

var 1 = AjaxTCR.comm.sendRequest
("http://ajaxref.com/ch3/setrating.php",
{ method: "GET",
serializeForm : "ratingForm",
outputTarget : "responseOutput"
});

var r2 = AjaxTCR.comm.sendRequest
("http://ajaxref.com/ch3/setrating.php",
{ method: "POST",
async : false,
payload : "rating=5&comment=Love+it",
outputTarget : "responseOutput"
});

TABLE 5-2 AjaxTCR.comm Methods

TABLE 5-3 Options for sendRequest()

Option Description Example(s)
async: Boolean Defines if the request should be
asynchronous or not. The default is
true.

async: false

insertionType:
"insertBefore" |
"insertAfter" |
"firstChild" |
"lastChild" |
"replace"

Used in conjunction with
outputTarget to define how
content returned should be handled
relative to the element specified
by the outputTarget value.
By default the returned content
will replace the outputTarget
element content. Other values
include:


  • insertBefore put as element
    just before the specified element

  • insertAfter put as an
    element just after the specified
    element

  • firstChild put as the first
    child within the specified element

  • lastChild put as the last child
    within the specified element


outputTarget : "responseDiv",
insertionType: "firstChild"
Free download pdf