SoFunction
Updated on 2025-04-06

js using ajax to read blog rss example


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<title>this is test</title>

<script type="text/javascript">
var xmlHttp;

function createXMLHttpRequest() {
    if () {
        xmlHttp = new ActiveXObject("");
    } 
    else if () {
        xmlHttp = new XMLHttpRequest();
    }
}

function readRSS(url) {
    createXMLHttpRequest();
    = handleStateChange;
    ("GET", url, true);
    (null);

  
}

function handleStateChange() {
    if( == 4) {
        if( == 200) {
            ResultSet();
        }
    }
}

function ResultSet() {
    var results = ;
    var title = null;
    var item = null;
    var link=null;
//Get channel
    var ccc=("channel");
     var headtitle=ccc[0].getElementsByTagName("title")[0].;
     var headlink=ccc[0].getElementsByTagName("link")[0].;
     var cell = ("div");
        ="<h1><a href="+headlink+" target=_blank>"+headtitle+"</a></h1>
";
        ("result").appendChild(cell);
//Get items
    var items = ("item");
    for(var i = 0; i < ; i++) {
        item = items[i];
        link=("link")[0].;
        title = ("title")[0].;
        var cell = ("div");
        ="<a href="+link+" target=_blank>"+title+"</a>
";
       ("result").appendChild(cell);
    }

}
function readrss1()
{
    var url=("txturl").value;
    if(url=="")
    {
alert("Please enter the RSS address");
        }
    else
        {
            readRSS(url);
            }
    }

</script>
</head>

<body">
<h1>ajax read rss example</h1>
  <form >

<a href="javascript:readRSS('/')">blogjava original area </a>
<a href="javascript:readRSS('/')">blogjava novices area </a>
<a href="javascript:readRSS('/')">blogjava non-technical area </a>
<a href="javascript:readRSS('/')">Comprehensive Zone </a>

 
Enter an RSS address: <input type="text" value="/wujun/" size=50 >
<input type="button" value="Check" onclick="readrss1()">

  </form>
    <div ></div>
</body>
</html>