Easy Tutorial
❮ Met Deletefile Met Getlasterror ❯

ASP - AJAX with ASP


AJAX is used to create more interactive applications.


AJAX ASP Example

The following example will demonstrate how a web page can communicate with a web server while a user types characters in an input field:

Example

Start typing a name in the input field below:

Suggestions:


Example Explanation - HTML Page

When a user types a character in the input field above, the "showHint()" function is executed. This function is triggered by the "onkeyup" event:

Source Code Explanation:

If the input field is empty (str.length==0), the function clears the content of the txtHint placeholder and exits the function.

If the input field is not empty, then showHint() performs the following steps:


ASP File

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

The source code in "gethint.asp" checks an array of names and returns the corresponding names to the browser:

Explanation: If JavaScript sends any text (i.e., strlen($q) > 0), then:

❮ Met Deletefile Met Getlasterror ❯