AJAX- How to Say Hello

<!--source code for firstFile.html-->

<html>

<head>

<script Language="Javascript" type="text/javascript">



function getDooma()

{

if (window.XMLHttpRequest)

{

return new XMLHttpRequest();

}

else if(window.ActiveXObject)

{

return new ActiveXObject("Microsoft.XMLHTTP");

}

else

{

alert("Your browser doesn't support this program");

}

}

var dooma=getDooma();

function sayGoodMorning()

{

if (dooma.readyState == 4 || dooma.readyState == 0)

{

dooma.open("GET","secondFile.html",true);

onreadystatechange=handleGoodMorning;

dooma.send(null);

}

}

function handleGoodMorning()

{

if (dooma.readyState == 4)

{

document.getElementById('showOutput').innerHTML=dooma.responseText;

}

}

</script>

</head>

<body>

<a href="javascript:sayGoodMorning();">

Say GoodMorning

</a>

<span id="showOutput"> </span>



</body>

</html>

<!--source code ends here-->

<!--source code for secondFile.html starts here-->

Good Morning Dooma!

<!--source code for secondFile.html end here-->

very good tutorial on ajax is available at dynamicajax.com


























































Say GoodMorning

















































Good Morning Dooma!







very good tutorial on ajax is available at dynamicajax.com












====





              



      

      

  


     









Before clicking the link , the page will look like this:





-------------------------------
After Clicking, the page will look like this:


Hello Pinky

--------------------------------------
Suppose if there is link as shown above, when we click that link, it will take you to some other page and display something. But ajax will do the same action at the BACKEND and can display something WITHOUT MOVING OUT OF THIS PAGE. As it is moving out of the page, it is called as ASYNCHRONOUS, As it uses, Javascript and xml, ajax stands for asynchronous javascript and xm

---------------------------------------------