AJAX works in FF but not IE/Chrome...
Posted: Fri Dec 18, 2009 10:31 am
So I did some AJAX, was pleased with myself as it all appeared to work - until I tried it in another browser that isn't FF!
In firefox it works perfectly, all the vars are set etc but when Chrome/IE gets hold of it the data is send through(I checked using alerts) but it isn't setting anything, unlike FF!
Here is the complete page code:
The only relevant area is really the AJAX/JS part though 
Thanks in advance!
Oscardog
In firefox it works perfectly, all the vars are set etc but when Chrome/IE gets hold of it the data is send through(I checked using alerts) but it isn't setting anything, unlike FF!
Here is the complete page code:
Code: Select all
<?php include("connection.php");
$totalgamesresult = mysql_query("SELECT * FROM games");
$totalgamesrow = mysql_num_rows($totalgamesresult);
if(!isset($_SESSION['username'])) {
die('<center>Only members can use this feature. Please create an account <a href="/register.php">here</a> and you will then be able to use this feature!</center>');
} ?>
<!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=utf-8" />
<title>On-Your-Break.com - Free Online Games. Right Here, Right Now! :: Members Ultimate Gaming Area</title>
<meta name="keywords" content="free, online, flash, games, your, on, break, bored, fun" />
<meta name="description" content="Offering free online games to all right here, right now!" />
<meta name="robots" content="all" />
<link href="/templatemo_style.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon" />
<script language="javascript" type="text/javascript">
function changeGame(){
var ajaxRequest;
try { ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP'); }
catch (e)
{
try { ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP'); }
catch (e2)
{
try { ajaxRequest = new XMLHttpRequest(); }
catch (e3) { xhr = false; }
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var gameInfo = ajaxRequest.responseText;
var splitInfo = gameInfo.split(",");
if(splitInfo[3] >= 915) {
splitInfo[3] = 915;
}
document.getElementById("gameTitle").innerHTML = splitInfo[1];
document.getElementById("gameSWF").width = splitInfo[3];
document.getElementById("gameSWF").height = splitInfo[4];
if(splitInfo[2].charAt(0) == "g") {
document.getElementById("paramembed").innerHTML = "<param name=\"movie\" value=\"/" + splitInfo[2] + ".swf\" /><param name=\"quality\" value=\"high\" />";
} else {
document.getElementById("paramembed").innerHTML = "<param name=\"movie\" value=\"" + splitInfo[2] + ".swf\" /><param name=\"quality\" value=\"high\" />";
}
if(splitInfo[2].charAt(0) == "g") {
document.getElementById("embedgame").innerHTML = "<embed src=\"/" + splitInfo[2] + ".swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + splitInfo[3] + "\" height=\"" + splitInfo[4] + "></embed>";
} else {
document.getElementById("embedgame").innerHTML = "<embed src=\"" + splitInfo[2] + ".swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + splitInfo[3] + "\" height=\"" + splitInfo[4] + "></embed>";
}
document.getElementById("gamewindow").style.visibility = "visible";
}
}
var url = "grabGameData.php"; // No question mark needed
var selectedGame = document.getElementById("gamemenu").value;
var params = "game=" + selectedGame;
ajaxRequest.open("POST",url,true);
ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajaxRequest.setRequestHeader("Content-length", params.length);
ajaxRequest.setRequestHeader("Connection", "close");
ajaxRequest.send(params);
}
</script>
</head>
<body>
<div id="templatemo_wrapper_outer">
<div id="templatemo_wrapper_inner">
<div id="templatemo_content_wrapper">
<div class="templatemo_content margin_right_10" style="float: none; margin: 0 auto; width: 920px;">
<div class="content_section">
<?php if(isset($_SESSION['username'])) { ?>
<h1 id="gameTitle">Select A Game...</h1>
<div id="leaderboard_bridge"></div>
<?php $currentURL = getenv("HTTP_HOST");?>
<div id="leaderboard_bridge"></div><script src="http://xs.mochiads.com/static/pub/swf/leaderboard.js" type="text/javascript"></script><script type="text/javascript">
var options = {partnerID: "77936ef9c9041bee", id: "leaderboard_bridge"};
options.username = "<?php echo $_SESSION['username']; ?>";
options.gateway = "<?php echo "http://" . $currentURL; ?>/mochidataparser.php";
options.sessionID = splitInfo[0];
options.globalScores = "true";
options.siteURL = "<?php echo "http://" . $currentURL; ?>";
options.siteName = "On Your Break";
Mochi.addLeaderboardIntegration(options);</script>
<div id="gamewindow" name="gamewindow" style="visibility: hidden">
<object style="text-align: center;" id="gameSWF" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="<?php echo $gamewidth; ?>" height="<?php echo $row['height']; ?>">
<div id="paramembed">
<param name="movie" value="<?php if(substr($row['gameurl'], 0, 5) == "games") { echo "/"; } echo $row['gameurl']; ?>.swf"/>
<param name="quality" value="high" />
</div>
<div id="embedgame"><embed src="<?php if(substr($row['gameurl'], 0, 5) == "games") { echo "/"; } echo $row['gameurl']; ?>.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="<?php echo $gamewidth; ?>" height="<?php echo $row['height']; ?>"></embed></div>
</object>
</div>
<form name="gameselect" id="gameselect" style="text-align:center; padding-top: 20px; padding-bottom: 20px;">
<select name="gamemenu" id="gamemenu" onChange="javascript:changeGame()" value="GO">
<option selected>Select A Game to play...</option>
<?php $gamesearchresult = mysql_query("SELECT * FROM games ORDER BY title ASC");
while($gamesearchrow = mysql_fetch_array($gamesearchresult)) {
echo "<option value=\"" . $gamesearchrow['title'] . "\">" . $gamesearchrow['title'] . "</option>";
} ?>
</select>
</form>
<div id="googlead" style="text-align: center;">
<script type="text/javascript"><!--
google_ad_client = "pub-0829015263123991";
/* 728x90, created 5/7/09 */
google_ad_slot = "7505255950";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<?php } ?>
<div class="margin_bottom_20 horizontal_divider"></div>
<div class="margin_bottom_20"></div>
<div class="margin_bottom_40"></div>
</div> <!-- end of content -->
<!-- end of right side bar -->
<div class="cleaner"></div>
</div> <!-- end of content wrapper -->
</div></div></div>
<div id="templatemo_footer">
<?php include("footer1.txt"); ?>
</div> <!-- end of footer -->
<div class="margin_bottom_10"></div>
<div class="content_section">
<div class="margin_bottom_10"></div>
</div>
</body>
</html>Thanks in advance!
Oscardog