Select Chapter ❯
PHP Tutorial
- PHP Introduction
- PHP Variables
- PHP Operators
- PHP Loops
- PHP Decision
- PHP Arrays
- PHP Functions
- PHP Forms
- PHP Include
- PHP File I/O
PHP Advanced
PHP Extra
PHP With Ajax
What is Ajax.? Ajax stands for Asynchronous JavaScript and XML. It is used to send and recieve data without page refresh.Examples of applications using AJAX: Google Maps, Gmail, Youtube, and Facebook tabs.
Example of PHP With AJAX
<html>
<head>
<script>
//Browser Support Code
function getvalue()
{
var request;
try
{
// Opera 8.0+, Firefox, Safari
request = new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer Browsers
try
{
request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
request.onreadystatechange = function()
{
if(request.readyState == 4)
{
document.write(request.responseText);
}
}
// Now get the value from user and pass it to
// server script.
request.open("GET", "getajax.php?name=" + str, true);
request.send();
}
</script>
</head>
<body>
<form>
First name: <input type="text" onkeyup="gatvalue(this.value)">
</form>
</body>
</html>
/*This is getajax.php file*/
<?php
$val = $_GET['name'];
echo "You Entered ".$val;
?>



