In some cases, this is useful because we
don't have to return an XML response.
If we wanted to simply display some basic text, instead of responding with an XML
document, we could respond with an XHTML snippet. However, we are trying to
deal with an XML response. This means that we need to parse the XML and update
the page accordingly.
This example builds on the JavaScript we used earlier. This time we have removed
the update setting and added the onComplete setting. The onComplete setting is a
function that is executed on completion of a request:
Chapter 10
[ 289 ]
// Update the page
this.send({ onComplete: function(response, responseXML)
{
alert('AJAX Response Received');
}});
The onComplete function is always passed two parameters, response and
responseXML. response is the RAW response. responseXML is an XMLDocument
object generated from the parsed response; this is the parameter in which we
are interested.
Remembering what our XML response looked like, we need to access the root node,
item.
Pages:
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397