How to use ajax to automatically load blogjava and rss of blog Park
This article will explain in detail how to use ajax to automatically load blogjava and rss in the blog Park. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
This is test
Var xmlHttp
Function createXMLHttpRequest () {
If (window.ActiveXObject) {
XmlHttp = new ActiveXObject ("Microsoft.XMLHTTP")
}
Else if (window.XMLHttpRequest) {
XmlHttp = new XMLHttpRequest ()
}
}
Function readRSS (url) {
CreateXMLHttpRequest ()
XmlHttp.onreadystatechange = handleStateChange
XmlHttp.open ("GET", url, true)
XmlHttp.send (null)
}
Function handleStateChange () {
If (xmlHttp.readyState = = 4) {
If (xmlHttp.status = = 200) {
ResultSet ()
}
}
}
Function ResultSet () {
Var results = xmlHttp.responseXML
Var title = null
Var item = null
Var link=null
Var author=null
Var pubDate=null
Var description=null
/ / get channel
Var ccc=results.getElementsByTagName ("channel")
Var headtitle=ccc [0] .getElementsByTagName ("title") [0] .firstChild.nodeValue
Var headlink=ccc [0] .getElementsByTagName ("link") [0] .firstChild.nodeValue
Var cell = document.createElement ("div")
Cell [XSS _ clean] = "" + headtitle+ "
"
Document.getElementById ("result") .appendChild (cell)
/ / get items
Var items = results.getElementsByTagName ("item")
For (var I = 0; I < items.length; iTunes +) {
Item = items [I]
Link=item.getElementsByTagName ("link") [0] .firstChild.nodeValue
Title = item.getElementsByTagName ("title") [0] .firstChild.nodeValue
Author=item.getElementsByTagName ("author") [0] .firstChild.nodeValue
PubDate= item.getElementsByTagName ("pubDate") [0] .firstChild.nodeValue
/ / description=item.getElementsByTagName ("description") [0] .firstChild.nodeValue
Var cell = document.createElement ("div")
Cell [XSS _ clean] = "" + title+ "& nbsp & nbsp & nbsp author:" + author+ "
"
Document.getElementById ("result") .appendChild (cell)
/ / var cell1=document.createElement ("div")
/ / Cell1 [XSS _ clean] = description
/ / document.getElementById ("result") .appendChild (cell1)
}
}
Function readrss1 ()
{
Var url=document.getElementById ("txturl"). Value
If (url== "")
{
Alert ("Please enter RSS address")
}
Else
{
ReadRSS (url)
}
}
Var iTunes 1
Var jung0
Function read ()
{
If (jacks 0)
{
ReadBlogjava ()
Window.setTimeout ("testRead ()")
}
}
Function testRead ()
{
Window.setTimeout ("read ()", 1000)
}
Function readBlogjava ()
{
Switch (I)
{
Case (1):
ITunes +
ReadRSS ("http://www.blogjava.net/rss.aspx");"
Break
Case (2):
ITunes +
ReadRSS ('http://beginner.blogjava.net/rss.aspx');
Break
Case (3):
ITunes +
ReadRSS ('http://general.blogjava.net/rss.aspx');
Break
Case (4):
ITunes +
ReadRSS ('http://life.blogjava.net/rss.aspx');
Break
/ / from the blog Park
Case (5):
ITunes +
ReadRSS ('http://www.cnblogs.com/rss.aspx');
Break
Case (6):
ITunes +
ReadRSS ('http://beginner.cnblogs.com/rss.aspx');
Break
Case (7):
ITunes +
ReadRSS ('http://life.cnblogs.com/rss.aspx');
Break
Case (8):
ITunes +
ReadRSS ('http://misc.cnblogs.com/rss.aspx');
Break
Case (9):
ITunes +
ReadRSS ('http://cio.cnblogs.com/rss.aspx');
Break
Case (10):
ITunes +
ReadRSS ('http://news.cnblogs.com/rss.aspx');
Break
Case (11):
ITunes +
ReadRSS ('http://bookreview.cnblogs.com/rss.aspx');
Break
Case (12):
ITunes +
ReadRSS ('http://job.cnblogs.com/rss.aspx');
Break
Case (13):
ITunes +
ReadRSS ('http://gis.cnblogs.com/rss.aspx');
Break
Case (14):
ITunes +
ReadRSS ('http://clubs.cnblogs.com/rss.aspx');
Break
Case (15):
ITunes +
ReadRSS ('http://software.cnblogs.com/rss.aspx');
Break
Default:
Alert ("loaded!")
ITunes +
Jacks +
Break
}
}
Ajax read rss example
Enter an RSS address:
On how to use ajax to automatically load blogjava and blog Park rss to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.