AJAX Database
 
AJAX can be used for interactive communication with a database.
The following example will demonstrate how a web page can fetch information from a database with AJAX:
 
 Book information will be listed here...
 The MySQL Database
The database table creation and population are given as follows:
 
  
   
    
CREATE TABLE bookList (
  ISBN      CHAR(16) PRIMARY KEY,
  title     VARCHAR(64) NOT NULL,
  authors   VARCHAR(64),
  price     REAL,
  quantity  INTEGER );
INSERT INTO bookList VALUES ( 
  '0596005601', 'Learning PHP 5', 'David Sklar', 19.77, 32 );
INSERT INTO bookList VALUES (
  '0596003064', 'High Performance MySQL', 'Jeremy D. Zawodny', 26.37, 221 );
   ... 
    
    | 
  
 
 The HTML Form
This AJAX contains an HTML form and a link to a JavaScript file.
When a user selects a book in the dropdown list above, a function called 
showBook is executed. 
The function is triggered by the 
onChange event:
 
  
   
    
<html>
 <head><script src="ShowBook.js"></script></head>
 <body><form action="">
  <select name="books" onChange="showBook(this.value)">
   <option value="">Select a book:</option>
   <option value="0596528388">AJAX</option>
   <option value="1118008189">HTML</option>
   ...
  </select></form>
  <div id="txtHint">Book information will be listed here...</div>
 </body>
</html> 
    
    | 
  
 
 
 
  
   
          
     Before you marry a person you should first make them use      
           a computer with slow internet to see who they really are.      
           — Will Ferrell
         
    |