$_GET[] with Ajax in IE 7
I have some code which uses some standard ajax:
function getLiveGame()
{
var gameid = "<?php echo $gameid ?>";
var xmlhttp;
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)
{
开发者_StackOverflow社区 document.getElementById("livegame1").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","livegame2.php?&refresh="+Math.random()+"&gameid="+gameid,true);
xmlhttp.send();
}
^Note the url it has also includes a Math.random to stop IE caching and also a 'gameid' which will be $_GET'ed later...
Now on livegame2.php the first few lines of code are:
$gameid = $_GET['gameid'];
echo $gameid;
Now on the page where this ajax is ran...
On firefox it says: 15 (which is the correctly passed gameid)
On IE it says: undefined (which is incorrect)
How can I get it working for IE/what is the problem?
Thanks alot,
精彩评论