//File is your php script called from the code
//above, myfile.php
<?php
//first we need to get the variables from the GET request,
//just as you would with any form submission. I'm being lazy
//here and not really doing security checks
//so be careful before putting this, verbatim, on a live server
$city = $_GET['city'];
$zip = $_GET['zip'];
//Here is where you contact your database / filesystem for
//information (in this case, the weather for the city and state
//sent in). Load it into a variable, we'll call it $response;
$response = database/file info
echo $response;
?>
Notice that we did not have to do anything special with the response text, just write it out to the page. The xmlHttp object reads the output of the page and uses it as its responseText.
That’s it for our introduction to using AJAX and the PHP scripting language. Play around with it for a bit, take it for a test drive, and come back later when we use a POST request to actually update information in our database and send a more complex XML query and response!