...

View Full Version : ticker-rss-ajax HELP!



Raoodo
12-10-2011, 11:00 AM
First of all sorry if i have posted in the wrong forum!

Ok my problem is with an RSS ticker for my website. I am having the error
req is not defined.

Im hoping its something very simple is the script is much complete!

THIS IS THE GRAB.PHP CODE


<?

// jim-jh@webcoding.co.uk
// ticker stuff - grab remote stream


// begin grab.php

$_receivedRemoteData = "" ;

$_requestedStream = $_SERVER['QUERY_STRING'];

if ( preg_match("/http/i", $_requestedStream ) ) {

$fp = @fopen( $_requestedStream, "r" ) ;

if ( $fp ) {

while ( !feof( $fp ) ) {

$_receivedRemoteData .= @fread($fp, 1024);

}

@fclose($fp);

}

}

header("content-type: text/xml") ;

print $_receivedRemoteData ;

// end grab.php


?>


THIS IS THE TICKER.PHP FILE CODE



<style>

.headlines {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
color: #003366;
text-decoration: none;
}
.headlines:hover {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 8pt;
font-weight: bold;
color: #003366;
text-decoration: none;
}
.globalheader {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-transform: uppercase;
color: #990000;
text-decoration: none;
}
</style>

<span align="left" width="100%" id="scroller" style="align:left;z-index:99; position:relative; display;">

<span class=globalheader>BBC NEWS RSS TICKER:</span><br/>
<span class="headlines">Loading RSS feeds....</span>

</span>

<script src="ticker.js"></script>


AND THIS IS THE JS CODE WHERE I THINK THE PROBLEM MAY BE.


function getRequest() {
var con = new Array();
var _ms_XMLHttpRequest_ActiveX = "";
var req;
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
if (_ms_XMLHttpRequest_ActiveX) {
req = new ActiveXObject(_ms_XMLHttpRequest_ActiveX);
} else {
var versions = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
for (var i = 0; i < versions.length ; i++) {
try {
req = new ActiveXObject(versions[i]);
if (req) {
_ms_XMLHttpRequest_ActiveX = versions[i];
break;
}
} catch (objException) {
// trap; try next one
}
}
}
}
con[0]=req;
con[1]=_ms_XMLHttpRequest_ActiveX;
return con;
}

function loadRSS(url) {
//alert("running");
try {
if ( _ms_XMLHttpRequest_ActiveX1 ) {
rssRequest.onreadystatechange = processRSS;
rssRequest.open("GET", url, true);
rssRequest.send(null);
} else {
if (rssRequest) {
rssRequest.onreadystatechange = processRSS;
rssRequest.open("GET", url, true);
rssRequest.send(null);
}
}
} catch ( rssRequestException ) {}
}


function getChildNode( myElement, naming ) {
return myElement.getElementsByTagName(naming)[0].firstChild.nodeValue;
}

function processRSS() {
var cycle = 0;
try {
if (rssRequest.readyState == 4) {
if (rssRequest.status == 200) {
response = rssRequest.responseXML.documentElement;
if ( response ) {
var items = response.getElementsByTagName("item");
for ( var i = 0 ; i < items.length; i++ )
{
var title = getChildNode(items[i],"title");
var desc = getChildNode(items[i],"description");
var link = getChildNode(items[i],"link");
rssItems[cycle] = title + " - " + desc;
linkItems[cycle] = link;
++cycle;
}
}
} else {
alert("There was a problem retrieving the XML data:\n" + req.statusText);
}
}
} catch ( jsException ) {alert(jsException.message);}
}

var httpArc2 = getRequest();
var rssRequest = httpArc2[0];
var _ms_XMLHttpRequest_ActiveX1 = httpArc2[1];

var rssItems = new Array();
var linkItems = new Array();


function openWindow(url){
window.open(url);
}



var storyCount = 0;
var itemLen = 0;

function tickTock(){

var obj = document.getElementById("scroller");

var myTimeout = 50;
var str;
var st = rssItems[storyCount];

if ( itemLen > st.length ) {
storyCount++;
if ( storyCount >= rssItems.length ) {
storyCount = 0;
}
itemLen = 0;
myTimeout=2000;
setTimeout("tickTock()", myTimeout);
} else {
++itemLen;
str = rssItems[storyCount].toString();
str = str.substring(0,itemLen) + "_";
obj.innerHTML = "<span class=globalheader>BBC NEWS RSS TICKER:</span><br/><a href=\"javascript:openWindow('"+linkItems[storyCount]+"')\" class=headlines>" + str + "</a>";
setTimeout("tickTock()", myTimeout);
}

}

setTimeout("tickTock()", 3000);


loadRSS("/grab.php?http://news.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml");





IS THERE ANYONE THAT CAN HELP WITH THIS?

VIPStephan
12-10-2011, 12:35 PM
In the future please enclose your code with
tags (e. g. by clicking the small ‘#’ button in the reply window) to post code. This makes reading your stuff a lot easier.

Raoodo
12-10-2011, 02:16 PM
This can be classed as now solved. Thankyou

VIPStephan
12-10-2011, 08:43 PM
Then edit your first post to select the “solved” prefix from the select box next to the title.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum