Join TalkersCode Now !

Get Latest Tutorials And Links On Web Development
And Get Existing Offers Via Email

PHP With Ajax

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; 
?>
Prev

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email

Are You Starting A New Blog
Do You Want Best Web Hosting?

Try World's Best Web Hosting Provider BlueHost
At Just $3.95/mo

Hurry Up! Limited Time Offer

Yes, I Want To Check Out BlueHost

Check The World's Best SEO And All-In-One Marketing Toolkit
For Digital Marketing Professionals SEMRUSH

Check Out SEMRUSH