This is an example of how to use jQuery in order to do an ajax request that will populate a select dropdown menu.

When a person types some data into these form elements:


That data can then be used (or not) in an AJAX request on this page. Data from the above form fields are sent to another script (fedex_ajax.php), which uses the values to generate some shipping methods and prices to stick in this dropdown menu below:

When you click the "Lookup Shipping rates" button, it triggers jQuery to grab all the values out of those other form boxes, and send them in the ajax request. jQuery then uses the result to re-make the last select menu on this page. The re-made dropdown box will have prices listed along with the labels (we are assuming that you don't know how much shipping will cost until your visitor inputs some of his address).

View source of this page to get the jQuery code. The source to the php script is here