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
|
<html>
<head>
<script language="javascript" src="../jquery/jquery-1.8.2.min.js"></script>
<script language="javascript">
// The API is passed the customer data and the name of the return function
function storeCustomer()
{
var customerID=document.getElementById("customerID").value;
var firstname=document.getElementById("firstname").value;
var lastname=document.getElementById("lastname").value;
var email=document.getElementById("email").value;
var address=document.getElementById("address").value;
$.ajax({
type: 'POST',
url: '../booking/makecustomer_XML.php',
data: { ID: escape(customerID),
firstname: escape(firstname),
lastname: escape(lastname),
email: escape(email),
address: escape(address),
},
success: ResultCustomer
});
}
function ResultCustomer(returnedData)
{
// Iterate over all nodes in root node (i.e. the 'created' element in root which has an attribute called status)
for (i = 0; i < returnedData.childNodes.length; i++) {
if(returnedData.childNodes.item(i).nodeName=="created"){
alert(returnedData.childNodes.item(i).attributes['status'].nodeValue);
}
}
}
</script>
</head>
<body>
<form>
ID: (is used to identify the user)<br><input type="text" id="customerID"> <br>
firstname:<br><input type="text" id="firstname"><br>
lastname:<br><input type="text" id="lastname"><br>
address:<br><input type="text" id="address"><br>
email:<br><input type="text" id="email"><br>
<input type="button" value="Store Customer" onclick="storeCustomer();">
</form>
</body>
</html>
|