michaelespinosa
10-12-2007, 07:40 PM
I am building a page for a school that will allow students to listen to there classes online. I did this using by having a page that has a list of the classes and when you click on one of the classes it uses js to load and external file into the current page. It works pretty good in all browsers except IE. It's shows Loading... but never finishes the request.
Here's (http://www.trsom.com/students/first_year/fall/a.php) the page I'm talking about.
Heres the JS
Inline link:
<a href="javascript:player('files/bt_1.php','player');">Week 1</a>
Linked JS:
function player(url,target) {
// native XMLHttpRequest object
document.getElementById(target).innerHTML = "Loading...";
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = function() {jahDone(target);};
req.open("GET", url, true);
req.send(null);
// IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = function() {jahDone(target);};
req.open("GET", url, true);
req.send();
}
}
}
function jahDone(target) {
// only if req is "loaded"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
results = req.responseText;
document.getElementById(target).innerHTML = results;
} else {
document.getElementById(target).innerHTML="audio error:\n" +
req.statusText;
}
}
}
Here's (http://www.trsom.com/students/first_year/fall/a.php) the page I'm talking about.
Heres the JS
Inline link:
<a href="javascript:player('files/bt_1.php','player');">Week 1</a>
Linked JS:
function player(url,target) {
// native XMLHttpRequest object
document.getElementById(target).innerHTML = "Loading...";
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = function() {jahDone(target);};
req.open("GET", url, true);
req.send(null);
// IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = function() {jahDone(target);};
req.open("GET", url, true);
req.send();
}
}
}
function jahDone(target) {
// only if req is "loaded"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
results = req.responseText;
document.getElementById(target).innerHTML = results;
} else {
document.getElementById(target).innerHTML="audio error:\n" +
req.statusText;
}
}
}