The following code is run when the page is load. it works on one page but when I use it on another pages for loading the feeds from different websites, it does not work. It is for RSSReader. I cannot understand why it works perfectly on one page but it does not work on another page.
<html>
<head>
<meta charset="utf-8" />
<title>******</title>
</head>
<script>
function showRSSi() {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (this.readyState==2) {
document.getElementById("artBody").innerHTML="loading....";
}
if (this.readyState==4 && this.status==200) {
document.getElementById("artBody").innerHTML=this.responseText;
}
}
xmlhttp.open("GET","RSS.php",true);
xmlhttp.send();
}
</script>
<body onload="showRSSi();">
<div id="artBody">
</div>
</body>
</html>
Thank you for your help.
if RSS.php lives in the root directory, that code will only work on the homepage and not on secondary pages. you can add a forward slash so your about page isn't looking for /about/RSS.php
xmlhttp.open("GET","/RSS.php",true);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.