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
Expand|Select|Wrap|Line Numbers
- <?php
- ...
- echo "<script type='text/javascript' src='./includes/getInfo.inc.js'></script>";
- ...
- include("didyouknow.php");
- ...
- ?>
didyouknow.php
Expand|Select|Wrap|Line Numbers
- <?php
- ...
- echo "<li><a href='#' onClick='getContent(\"didyouknow\", \"4\", \"dyk\")'>Frames</a></li>";
- ...
- ?>
getInfo.inc.js
Expand|Select|Wrap|Line Numbers
- 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)
Expand|Select|Wrap|Line Numbers
- <?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.onreadystatechange = function(){setOutput(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