php ajax and Firefox mozilla?

Unknown

New member
Following script works in Explorer but not in Mozilla Firefox please help me.

<html>
<body>
<script type="text/javascript">
var xmlhttp;

function showUser(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="test.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
</script>

<a href="#" value="1" onClick="showUser(this.value)">click problem</a>
</body>
</html>

test.php ==>

<?php
$q=$_GET["q"];
echo $q;
?>

when i click on CLICK PROBLEM it display "1" in explorer but in Firefox it display "undefined". Whats the problem??/
Above code works fine in Internet Explorer but not in Firefox 3.
 
It might be that you're using innerText - I can't see what you've put here -

document.getElementById("txtHint").inn…

- as Yahoo has truncated it. If you are trying to use innerText then that will be the issue as it is an IE only property. Use innerHTML instead.
 
It might be that you're using innerText - I can't see what you've put here -

document.getElementById("txtHint").inn…

- as Yahoo has truncated it. If you are trying to use innerText then that will be the issue as it is an IE only property. Use innerHTML instead.
 
Back
Top