need help in ajax
Posted: Wed Jun 17, 2009 7:09 am
Hi,
Am using an ajax function in bottom of my webpage to display the details of a select name.
when i click on the link, the page is moving to the top. the following is the script i used.
Ajax Function:
The div id, where the to value display:
Am using an ajax function in bottom of my webpage to display the details of a select name.
when i click on the link, the page is moving to the top. the following is the script i used.
Ajax Function:
Code: Select all
function Todisplaydescription(val)
{
//alert(stuid);
var httpxml;
try
{
// Firefox, Opera 8.0+, Safari
httpxml=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
httpxml=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
httpxml=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
function stateck()
{
if(httpxml.readyState==4)
{
document.getElementById("description").innerHTML=httpxml.responseText;
}
}
var url="pagename.php";
url=url+"?val="+val;
httpxml.onreadystatechange=stateck;
httpxml.open("GET",url,true);
httpxml.send(null);
}
</script>Code: Select all
<a href="#" onclick="Todisplaydescription('somevalue')" >Example </a>
<div id="description"></div>