/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/AjaxDemoApp1_storeCustomer_description.html

  • Committer: Gustav Hatvigsson
  • Date: 2013-05-17 09:46:50 UTC
  • mfrom: (69.3.3 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130517094650-cjpddwztwm0hh0pk
Merged Gostavssons changes: rwemoved lots of old files and changed to the database file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<span class="description">
2
 
<br>
3
 
<div class="descriptionheading">Overview</div>
4
 
 
5
 
The storage application collects the id,name,address and email from a form and sends it to the api which promptyl creates a new customer.<br><br>
6
 
 
7
 
<div class="descriptionheading">storeCustomer</div>
8
 
The function called <span class="interestingdescription">storeCustomer</span> is executed by the onclick event of the form at the bottom of the code. 
9
 
The click event is useful for things such as processing form data after a mouse click on a button/image/div/span etc.
10
 
The $.ajax function is part of the jQuery api and sends a POST request to booking/makecustomer_XML.php which adds a customer to the database.
11
 
 The data from the form (for example <span class="interestingdescription">customerID</span>) is retrieved to a set of variables that are then sent to the api.
12
 
<br><br>
13
 
 
14
 
<div class="descriptionheading">ResultCustomer</div>
15
 
 
16
 
The other function <span class="interestingdescription">ResultCustomer</span> is called automatically by jQuery when the data has been returned. 
17
 
 
18
 
<br><br><div class="descriptionheading">booking/makecustomer_XML.php</div>
19
 
 
20
 
MakeCustomer makes an insert to the database. The function makes no checks on the data, and if any error occurs, the error message is returned as a status message.<br>
21
 
 
22
 
<br><div class='exampleheading'>Api Call Example:<br><br>
23
 
<pre class="codeexample">
24
 
$.ajax({
25
 
        type: 'POST',
26
 
        url: 'booking/makecustomer_XML.php',
27
 
        data: { ID: escape(customerID),
28
 
                firstname: escape(firstname),
29
 
                lastname: escape(lastname),
30
 
                email: escape(email),
31
 
                address: escape(address),
32
 
        },
33
 
        success:  ResultCustomer
34
 
});</pre>
35
 
</div>
36
 
 
37
 
<br>
38
 
 
39
 
<br><div class='exampleheading'>Returned Data Example:<br><br>
40
 
<span class="codeexample">&lt;created status="Error: Duplicate entry 'Haakon' for key 1"/&gt;</span>
41
 
</div>
42
 
                                                                                                                                        
43
 
</span>