44 Part I: Core Ideas
Yet to consume such content, you would need to go into the packet, extract the
particular data items, and insert it into the parent XHTML document. The code to do that is
shown here and is actually quite terse compared to how it can get with a more complex
XML response format:
function handleResponse(ifr)
{
/* clear network timeout */
if (timer)
clearTimeout(timer);
var ifrDoc = null;
var xmlDoc = null;
var ifrWindow = ifr.contentWindow || ifr.contentDocument;
if (ifrWindow.document)
ifrDoc = ifrWindow.document;
else
ifrDoc = ifrWindow;
if (ifrDoc.XMLDocument)
xmlDoc = ifrDoc.XMLDocument;
else
xmlDoc = ifrDoc;
FIGURE 2-6 Two-way iframes with a script response