3
<script language="javascript" src="../jquery/jquery-1.8.2.min.js"></script>
5
<script language="javascript">
7
// The API is passed a customer ID and the name of the return function
8
function showCustomer()
10
customerID = "haakon";
14
url: '../booking/getcustomer_XML.php',
15
data: { customerID: escape(customerID)},
16
success: ResultCustomer
20
function ResultCustomer(returnedData)
22
// An XML DOM document is returned from AJAX
23
var resultset=returnedData.childNodes[0];
25
// Iterate over all nodes in root node (i.e. customers)
26
for (i = 0; i < resultset.childNodes.length; i++) {
27
// Iterate over all child nodes of that node that are customer nodes
28
if(resultset.childNodes.item(i).nodeName=="customer"){
29
// Retrieve first name and last name for node
30
var customer=resultset.childNodes.item(i);
31
alert(customer.attributes['firstname'].nodeValue+' '+customer.attributes['lastname'].nodeValue);
37
<body onload='showCustomer();'>
38
Showing alert with information about customer with customerID: haakon