AJAX PHP Example

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

In the example below, when a user types a character in the input field, a function called showHint() is executed.

The function is triggered by the onkeyup event.

Here is the code:

EXAMPLE ❯


The PHP File - "gethint.php"

The PHP file checks an array of names, and returns the corresponding name(s) to the browser:

EXAMPLE ❯