Forum Moderators: open
Basically I have a php script that produces a random quote everytime the page gets loaded. Found a script that does this via js/ajax so it saves reloading the entire page. Works great in firefox (both pc and mac) safari (pc definatly) but not ie6 ie7 or opera.
Well, it kinda works in the last 3, but it only refreshes once. Whenever i press the link to refresh, nothing happens. No errors appear in either ie6 or 7.
The following is the javascript thats called in at the top of the page in the head
function getdata(dest) {
try {
xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
}
xmlhttp.onreadystatechange = triggered;
xmlhttp.open("GET", dest);
xmlhttp.send(null);
}
function triggered() {
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
document.getElementById("quote").innerHTML = xmlhttp.responseText;
}
} And the following is the html bit in the page
<div id="quote"><?php include('randomscript.php');?></div>"
<p>(<a onclick="getdata('randomscript.php','quote');">Refresh</a></p>
Any ideas and help to get it working across all browsers would be much appreciated
:)