آقا من سرچ کردم تو سایتهای دیگه ولی جوابهایی که داده بودن هیچ کدوم درست نبود.
چرا این کد توی IE کار می کنه ولی توی FireFox کار نمی کنه؟
کد صفحه دیگر
من احتمال میدم که مشکل از این قسمت باشه :
ولی نمی دونم چطور باید حل بشه.
چرا این کد توی IE کار می کنه ولی توی FireFox کار نمی کنه؟
کد پیاچپی:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript">
var pageurl = "getName.php?param=";
var http = getHttp();
function Answer()
{
if(http.readystate==4)
{
r = http.responseText;
document.getElementById("tfname").value = r;
}
}
function SendCodeAndReciveName()
{
var code = document.getElementById("tfcode").value;
http.open("GET", pageurl+code, true);
http.onreadystatechange = Answer;
http.send(null);
}
function getHttp()
{
var xmlhttp;
try
{
xmlhttp = new ActiveXObject("msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
if(typeof XMLHttpRequest != "undefined")
{
xmlhttp = new XMLHttpRequest();
}
}
}
return xmlhttp;
}
</script>
</head>
<body>
<p>code :
<input name="tfcode" type="text" id="tfcode" />
<input type="button" name="Submit" value="get name" onClick="SendCodeAndReciveName()" />
<br />
<br />
city name:<input name="tfname" type="text" id="tfname" />
</p>
</body>
</html>
کد پیاچپی:
<?php
$c = $_GET["param"];
if($c == "0311")
{
echo "Esfahan";
}
else
echo "UnKnown"
?>
کد پیاچپی:
catch(e)
{
if(typeof XMLHttpRequest != "undefined")
{
xmlhttp = new XMLHttpRequest();
}