Magazine
 
Quick Review:Ajax
 

Five common Ajax patterns

 

var nli = nl.item( i );
var elAuthor = nli.getElementsByTagName( ‘author’ );
var author = elAuthor.item(0).firstChild.nodeValue;
var elTitle = nli.getElementsByTagName( ‘title’ );
var title = elTitle.item(0).firstChild.nodeValue;
var elTr = dtable.insertRow( -1 );
var elAuthorTd = elTr.insertCell( -1 );
elAuthorTd.innerHTML = author;
var elTitleTd = elTr.insertCell( -1 );
elTitleTd.innerHTML = title;
} } }
function loadXMLDoc( url ) {
if(window.XMLHttpRequest) {
try { req = new XMLHttpRequest();
} catch(e) { req = false; }
} else if(window.ActiveXObject) {
try { req = new ActiveXObject(‘Msxml2.XMLHTTP’);
} catch(e) {
try { req = new ActiveXObject(‘Microsoft.XMLHTTP’);
} catch(e) { req = false; }
} }
if(req) {
req.onreadystatechange = processReqChange;
req.open(‘GET’, url, true);
req.send(‘’);
}
}
var url = window.location.toString();
url = url.replace( /pat2_xml.html/, ‘pat2_xml_data.xml’ );
loadXMLDoc( url );
</script>
</head>
<body>
<table cellspacing=”0" cellpadding=”3" width=”100%”>
<tbody id=”dataBody”>
<tr>
<th width=”20%”>Author</th>
<th width=”80%”>Title</th>
</tr>
</tbody>
</table>
</body>
</html>

Listing 9 shows the data for the page.

Apr 2008 | Java Jazz Up | 69
previous
index
next
 
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70, 71, 72, 73, 74, 75, 76, 77, 78,   Download PDF