/lenasys/0.1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/0.1

« back to all changes in this revision

Viewing changes to trunk/Code Viewer Alt/AJAX/AjaxDemoApp0_getCustomer.html

  • Committer: Henrik G.
  • Date: 2013-03-26 23:22:55 UTC
  • Revision ID: henrik.gustavsson@his.se-20130326232255-ik6snyatlbkf3zs1
First seed of Lenasys ... Needs to be Organized Further

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
<head>
 
3
        <script language="javascript" src="../jquery/jquery-1.8.2.min.js"></script>
 
4
 
 
5
<script language="javascript">
 
6
 
 
7
        // The API is passed a customer ID and the name of the return function
 
8
        function showCustomer()
 
9
        {
 
10
                customerID = "haakon";
 
11
 
 
12
                $.ajax({
 
13
                        type: 'POST',
 
14
                        url: '../booking/getcustomer_XML.php',
 
15
                        data: { customerID: escape(customerID)},
 
16
                        success:  ResultCustomer
 
17
                });
 
18
        }
 
19
        
 
20
        function ResultCustomer(returnedData)
 
21
        {
 
22
                // An XML DOM document is returned from AJAX
 
23
                var resultset=returnedData.childNodes[0];
 
24
 
 
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);
 
32
                                }
 
33
                }
 
34
        }                               
 
35
</script>
 
36
</head>
 
37
<body onload='showCustomer();'>
 
38
        Showing alert with information about customer with customerID: haakon
 
39
        
 
40
</body>
 
41
</html>