Here's a good one i can't figure out. I have an AJAX application running off a PHP script and it works fine in FF(3.6.3), Safari(4.0.5), BUT it won't work in IE(8.0.76)[either 32bit or 64bit], and i can't figure out why.
By not working, i mean that my div's content (named: dyk) won't update in IE, but updates fine in other browsers when clicking on a link (though a JS onClick event).
Here's my code so far:
index.php
didyouknow.php
getInfo.inc.js
didyouknow_Info .php (simple code for testing)
That's what i have so far.
When executing the code, i get no JS errors or any other errors.
With the help of JS alerts in my JS script, i've come to figure out that in IE, httpObject.onre adystatechange = function(){setO utput(eid);}; won't always fire when i click on a link (but the rest of the JS script works fine).
Any help and thoughts are greatly appreciated!!
Thank you!
Duke
By not working, i mean that my div's content (named: dyk) won't update in IE, but updates fine in other browsers when clicking on a link (though a JS onClick event).
Here's my code so far:
index.php
Code:
<?php
...
echo "<script type='text/javascript' src='./includes/getInfo.inc.js'></script>";
...
include("didyouknow.php");
...
?>
didyouknow.php
Code:
<?php ... echo "<li><a href='#' onClick='getContent(\"didyouknow\", \"4\", \"dyk\")'>Frames</a></li>"; ... ?>
getInfo.inc.js
Code:
var httpObject = null;
var adrs;
// Get the HTTP Object
function getHTTPObject(){
if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) return new XMLHttpRequest();
else {
alert("Your browser does not support AJAX.");
return null;
}
}
// Change the value of the div
function setOutput(eid){
if(httpObject.readyState == 4){
document.getElementById(eid).innerHTML = httpObject.responseText;
alert("blah");
}
}
// Implement logic
function getContent(page, section, eid){
httpObject = getHTTPObject();
adrs=page+"_Info.php?s="+section;
if (httpObject != null) {
httpObject.open("GET", adrs, true);
httpObject.send(null);
httpObject.onreadystatechange = function(){setOutput(eid);};
}
}
didyouknow_Info .php (simple code for testing)
Code:
<?php
if($_GET){
$s = $_GET['s'];
}
echo "<p class='lg'>";
switch ($s) {
case 1:
echo "Section ".$s;
break;
case 2:
echo "Section ".$s;
break;
case 3:
echo "Section ".$s;
break;
default:
echo "Section doesn't exist.";
}
echo "</p>";
?>
When executing the code, i get no JS errors or any other errors.
With the help of JS alerts in my JS script, i've come to figure out that in IE, httpObject.onre adystatechange = function(){setO utput(eid);}; won't always fire when i click on a link (but the rest of the JS script works fine).
Any help and thoughts are greatly appreciated!!
Thank you!
Duke
Comment