Ajax Request

<script type="text/javascript">
function ajaxLoadFile()
{
if(window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
else xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");//For Ie5+Ie6

xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) document.getElementById("ajax-target-div").innerHTML = xmlhttp.responseText;
}
xmlhttp.open("GET","/ajax-test.php",true);
xmlhttp.send();
}
</script>

<div id="ajax-target-div">
<p>Text to be replaced by file loaded via Ajax</p>
</div>

<button type="button" onclick="ajaxLoadFile();">Load file with Ajax</button>

0 Comments

You must be logged in to post a comment.