This lesson will
walk you through the process of creating a simple PHP script that displays the current
server time.The XMLHttpRequest property, responseText, will store the data
that this PHP script displays to the browser, so all we want this script to do is echo the current time.
Ajax - Server-Side PHP Script
This lesson will
walk you through the process of creating a simple PHP script that displays the current
server time.
Ajax - serverTime.php File
The XMLHttpRequest property, responseText, will store the data
that this PHP script displays to the browser, so all we want this script to do is Echo the current time. The
php code below should be saved in the same directory as "order.html".
serverTime.php PHP Code:
<?php
echo date("H:i:s");
?>
Ajax - Run Your Ajax!
Below is a working version of the simple, yet super cool, Ajax application you have
just created! To test it out just type some text into the "Name:" text box, then
click inside the "Time:" text box.
Display of order.html:
Name:
Time:
Sweet! The time text box pulled down the server's time from "serverTime.php" without
having to reload the entire page! Congratulations you've just written your first
fully-functional Ajax application!
Ajax - Continued Learning
That's all for now folks! If you're feeling adventerous about taking
your Ajax skills to the next level, then I highly recommend you check
out IBM's Master Ajax Series
|