To see how
AJAX works, we will develop small
AJAX Web Application.
First of all we need some
HTML file with forms to input data. This will be one input field where we can write some text. In our case this will be some name. This
HTML file we will save under ajax.html name. The code of
HTML file can taken from box bellow: (Please note that the text input handle onkeypress event and call to
ajax(); function and there is no “Submit” button in
HTML form)
Next we have to prepare small
PHP file. This is the server-side file where the requests will sends and
AJAX function will get the result. We use some
PHP array for store the names. And will check for match with stristr() case-insensitive function. You can use the code below:
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 1 Jan 1990 01:00:00 GMT");
$names=array(John,Will,Kelly,Diana,Robert,Nina,George,Michael,Clint,Debora,Nick,Jeff,Kevin,Samuel,David,Peter,Patrick,Quest,Silvia,Umbro,William,Zita,Yantra,Xena,Albert,Ulrich);
for ($i=0;$i<count($names);$i++) {
if (stristr($names[$i], $_GET[data])) {
$result.=$names[$i]."\n";
}
}
echo nl2br($result);
?>
posted on 2009-Aug-09 | 04:52:38 PM
it is so usefull
posted on 2009-Nov-24 | 05:09:59 AM
regards
http://www.srisoftwarez.com
posted on 2009-Dec-11 | 01:25:53 AM
posted on 2010-Jul-30 | 09:26:03 AM