Hi guys,
I'm trying to initiate an ajax event from an onclick.
my link code is:
and my javascript is
in an external file
I cannot for the life of me work out why I'm getting "id is undefined" errors in firefox, can you guys give me some pointers?
Thanks in advance
I'm trying to initiate an ajax event from an onclick.
my link code is:
Code:
<a href="404.html" onclick="getContent('test'); return false;">something</a>
Code:
function getContent()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("main-content").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","./lib/page.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("page_id=" + id)
xmlhttp.send();
}
I cannot for the life of me work out why I'm getting "id is undefined" errors in firefox, can you guys give me some pointers?
Thanks in advance
Comment