PHPBuilder - Introduction to PHP and Ajax Page 2



RSS Twitter
Articles Html

Introduction to PHP and Ajax - Page 2

by: Anthony Corbelli
|
September 19, 2008

//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!



« Previous Page
1
|
2

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Anthony Corbelli

Comment:



Comment:

(Maximum characters: 1200). You have characters left.