The AJAX HTML Page
This is the HTML page. It contains a simple HTML form and a link to a JavaScript.
First Name:
<input type="text" id="txt1" onkeyup="showHint(this.value)"/> <p>Suggestions: <span id="txtHint"></span></p>
The JavaScript code is listed below.
The AJAX JavaScript
This is the JavaScript code, stored in the file “clienthint.js”:
var xmlHttp
function showHint(str)
{
if (str.length==0)
{
document.getElementById("txtHint").innerHTML="";
return;
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="tutorialz.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
The AJAX Server Page -PHP
There is no such thing as an AJAX server. AJAX pages can be served by any internet server.
AJAX PHP Example
The code in the “tutorialz.php” page just checks an array of names and returns the corresponding names to the client:
Note: Code below is tutorialz.php
PHP Example
// Fill up array with names
$a[]="Google";
$a[]="Yahoo";
$a[]="Hotmail";
$a[]="Java";
$a[]="PHP";
$a[]="Asp";
$a[]="Ajax";
$a[]="Javascript";
$a[]="Ruby";
$a[]="Ecllipse";
$a[]="Dreamweaver";
$a[]="Flash";
$a[]="Photoshop";
$a[]="Fireworks";
$a[]="Flex";
$a[]="hass";
$a[]="marcelo";
$a[]="luciano";
$a[]="thiago";
$a[]="pallero";
$a[]="mozin";
$a[]="angush";
$a[]="gary";
$a[]="mike";
$a[]="perotti";
$a[]="michael";
$a[]="angelo";
$a[]="remoiv";
$a[]="asne";
$a[]="jack";
//get the q parameter from URL
$q=$_GET["q"];
//lookup all hints from array if length of q>0
if (strlen($q) > 0)
{
$hint="";
for($i=0; $i
{
if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q))))
{
if ($hint=="")
{
$hint=$a[$i];
}
else
{
$hint=$hint." , ".$a[$i];
}
}
}
}
// Set output to "no suggestion" if no hint were found
// or to the correct values
if ($hint == "")
{
$response="no suggestion";
}
else
{
$response=$hint;
}
//output the response
echo $response;
Incoming search terms:
- ajax page php (7)
- ajax page in php (5)
- javascript and ajax tutorial 5 case 3 (2)
- auto textbox search in php demos (2)
- fetch value into combobox from database using symfony (2)
- simple ajax php example (2)
- yii how to make country dropdown list through xml file (2)
- listbox syntax example in yii (1)
- jquery ajax onchange php code (1)
- javascript tutorial 5 case 3 (1)
- yii pass value from dropdownlist (1)
- javascript and ajax tutorial 1 case 3 (1)
- html tutorial 5 case 3 (1)
- how to pass textbox field value click on ajax button in yii (1)
- how to fetch country names from database using dropdown in yii (1)
- how to execute country list from sql by showHint() (1)
- getvalue java dropdown yii (1)
- stylish pop ups in jquery (1)
- login page using ajax code (1)
- pass textbox array values with ajax (1)
- span id=countdown1 ajax (1)
- yii ajax dropdownlist from database (1)
- show hint from array ajax (1)
- search and display data in php using textbox onchange (1)
- return a page from php to ajax (1)
- php in ajax pages (1)
- php dollar nkeyup=showhint(this value) (1)
- php ajax page (1)
- Yii ajaxPager (1)
- php ajax countdown (1)
- PHP ajax login (1)
- explorer yii ajax dropdown (1)
- ajax search yii (1)
- ajax php one page (1)
- ajax php add item to dropdown list (1)
- ajax pages with php (1)
- ajax pages php url (1)
- ajax pages can be served yb (1)
- ajax pages can be served by (1)
- ajax combo php auto (1)
You will also be interested in ,
- Simple Ajax with PHP click tracker
- Automatic Ajax Loading Images With Prototype
- Ajax and Jquery
- How to use Namespaces in php 5.3 ?
- Zip or Archive a directory using php
- working with directories using php
- Getting Remote Webpage Info Using PHP
- Avoid direct access to a file in php enhanced version
- Simple Visitor Counter Using php
- How to get the IP address of the visitor with PHP?

nice website keep going….
hmm wooww
yup..
good one..
A good website with good inputs….hats off
a coool……..site
HMM
best of its kind
a nice one..
fine
not bad..
http://community.fitnessanywhere.com/members/vbest12.aspx – christina milian nude christina milian nude
a nice one
Good ajax stuff and php
cool site
maudg3 http://google.com