Easy Tutorial
❮ Prop Item Met Write Response ❯

AJAX Database Example


AJAX can be used to interact with databases for interactive communication.


AJAX Database Example

The following example will demonstrate how a web page can retrieve information from a database using AJAX:

Example


Example Explanation - HTML Page

When a user selects a customer from the dropdown list above, a function called "showCustomer()" is executed. This function is triggered by the "onchange" event:

Source Code Explanation:

If no customer is selected (str.length == 0), the function will clear the txtHint placeholder and then exit.

If a customer is selected, the showCustomer() function will perform the following steps:


ASP File

The server page called by the JavaScript above is an ASP file named "getcustomer.asp".

The source code in "getcustomer.asp" will run a query against the database and return the results in an HTML table:

❮ Prop Item Met Write Response ❯