/lenasys/trunk

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

« back to all changes in this revision

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

  • Committer: Gustav Hartvigsson
  • Date: 2013-04-12 19:13:58 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20130412191358-lvnmll48cw7idkzk
added:
* COPYING - licensing information
* COPYRIGHT_HEADER - the header that should be in every file related to
  the project.
* README - Information about the project.
* lgpl-3.0 - The license that is used by this project.

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
                <script language="javascript">
 
5
                        // The API is passed a customer ID and the name of the return function
 
6
                        function showCustomer() {
 
7
                                customerID = "haakon";
 
8
                                $.ajax({
 
9
                                        type: 'POST',
 
10
                                        url: '../booking/getcustomer_XML.php',
 
11
                                        data: { customerID: escape(customerID)},
 
12
                                        success:  ResultCustomer
 
13
                                });
 
14
                        }
 
15
                        function ResultCustomer(returnedData) {
 
16
                                // An XML DOM document is returned from AJAX
 
17
                                var resultset=returnedData.childNodes[0];
 
18
                                // Iterate over all nodes in root node (i.e. customers)
 
19
                                for(i = 0; i < resultset.childNodes.length; i++) {
 
20
                                        // Iterate over all child nodes of that node that are customer nodes
 
21
                                        if(resultset.childNodes.item(i).nodeName=="customer"){
 
22
                                                // Retrieve first name and last name for node
 
23
                                                var customer=resultset.childNodes.item(i);
 
24
                                                alert(customer.attributes['firstname'].nodeValue+' '+customer.attributes['lastname'].nodeValue);
 
25
                                        }
 
26
                                }
 
27
                        }                               
 
28
                </script>
 
29
        </head>
 
30
        <body onload='showCustomer();'>
 
31
                Showing alert with information about customer with customerID: haakon
 
32
        </body>
 
33
</html>