Hi All,
I am new to Ajax. I wrote my first script with the help of Google :) Please let me know the mistake. I have three menu and it is supposed to load three pages. I used firebug but unable to see any error.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>test page</title>
<script type="text/javascript">
function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}
page_request.open('GET', url, true)
page_request.send(null)
}
</script>
</head>
<html>
<body>
<div class="leftdiv" style="float:">
<a href="javascript:ajaxpage('page1.htm', 'rightdiv');">Menu1</a>
<a href="javascript:ajaxpage('page2.htm', 'rightdiv');">Menu2</a>
<a href="javascript:ajaxpage('page3.htm', 'rightdiv');">Menu3</a>
</div>
<div class="rightdiv" style="float:right;left;"></div>
</body>
</html>