Ajax Example

Using MySQL and the race table - this gets all rows that match any part of first name and last name.



Try 2009 and Jim (Elmore or Ryan)
Example:
Year:
Name:



Source

JS source
PHP Source If you are using Internet Explorer, you will have to click on this link and then click on View->Source

another Ajax Example

How To Debug the Code:

1. PHP - Uncomment the two lines
// $_GET['LastName'] = "crai";
// $_GET['year'] = 2009;

and run this program from the command line with

php getRaceEntry.php

It will return these values:

5
Craig Young M 2124
Angela Craig F 1723
Craig Abrahamson M 1705
Leah Craig F 1457
Craig Sarazin M 651
2. Javascript - Uncomment the line
alert( name + " - " + year);

and refresh the page and enter or delete a character in the name field to see that the values are being passed properly to the Javascript. In Firefox, check the Error Console (under Tools) to see if there are any Javascript errors in your code. Put alert statements elsewhere in your js code if you have other questions.

Suggested Readings