PDA

View Full Version : Resolved FAIL - Multiple XMLHttpRequest on Share Point web site fails



talpav
04-07-2010, 12:11 AM
Trying to embed two copies of a JS scrolling ticker web part on a share point page. The code is below. The ticker gets a Share POint list as an RSS feed.

It works fine when only one ticker is embedded in a Content Editor web part. When embedding two, only the older one shows. The newer one displays the first message in the code below: "Something is wrong with the RSS Feed..."

Obviously, it seems to not be getting past that line of code.

Sorry, completely new to this... any ideas?



<html>
<head>
<title>JavaScript RSS ticker</title>
<style type="text/css"><!--
body {
font-family: Arial;
}
#ticker1 {
font-size: 13pt;
background-color: #D6E8FF;
}
--></style>
</head>
<body>

<script type="text/javascript" language="JavaScript">
function rss_ticker1(url) {
// Create ticker div
document.write('<div id="ticker1">Something is wrong with the RSS Feed...<div>');

// Create XMLHttpRequest object
try {
xy = new ActiveXObject('Msxml2.XMLHTTP');
}
catch(e) {
try {
xy = new ActiveXObject('Microsoft.XMLHTTP');
}
catch(oc) {
xy = null;
}
}
if(!xy && typeof XMLHttpRequest != 'undefined') xy = new XMLHttpRequest();

// Get the RSS feed
xy.open('GET', url, true);
xy.send(null);
xy.onreadystatechange = function() {
if (xy.readyState == 4&&xy.status==200) {
parse_data(xy.responseText);
}
}

}

// Parse the RSS feed and write to the ticker div
function parse_data(data) {
var pos = 0;
var ticker1 = document.getElementById('ticker1');
ticker1.innerHTML = '';
while((pos = data.indexOf('<item>', pos+1)) != -1) {
title_b = data.indexOf('<title>', pos);
title_e = data.indexOf('</title>', pos);
title_s = data.substr(title_b+7, title_e-title_b-7);

link_b = data.indexOf('<link>', pos);
link_e = data.indexOf('</link>', pos);
link_s = data.substr(link_b+6, link_e-link_b-6);

start_s = "➦"
seperator_s = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"

ticker1.innerHTML += ''+start_s+'<a href="' +link_s+ '">'+title_s+' '+seperator_s+' </a>';
}
}
</script>

<marquee behavior="scroll" direction="left" scrollamount="5" width=100% onmouseover="this.stop();" onmouseout="this.start();">

<script type="text/javascript" language="JavaScript">
rss_ticker1('http://www.VALID_RSS_URL_1.com/');
</script>

</marquee>
</body>
</html>