Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-10-2011, 11:00 AM   PM User | #1
Raoodo
New to the CF scene

 
Join Date: Dec 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Raoodo is an unknown quantity at this point
ticker-rss-ajax HELP!

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

PHP Code:
<?

    
// [email]jim-jh@webcoding.co.uk[/email]
    // 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($fp1024);

            }

            @
fclose($fp);

        }

    }

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

    print 
$_receivedRemoteData ;

    
// end grab.php


?>
THIS IS THE TICKER.PHP FILE CODE

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.

PHP Code:
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 
0versions.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"urltrue);
                
rssRequest.send(null);
            } else {
                if (
rssRequest) {
                    
rssRequest.onreadystatechange processRSS;
                    
rssRequest.open("GET"urltrue);
                    
rssRequest.send(null);
                }
            }
        } catch ( 
rssRequestException ) {}
    }


    function 
getChildNodemyElementnaming ) {
        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 
items.lengthi++ )
                        {
                            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?

Last edited by VIPStephan; 12-10-2011 at 12:34 PM.. Reason: wrapped code tags
Raoodo is offline   Reply With Quote
Old 12-10-2011, 12:35 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,697
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
In the future please enclose your code with [CODE][/CODE] tags (e. g. by clicking the small ‘#’ button in the reply window) to post code. This makes reading your stuff a lot easier.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 12-10-2011, 02:16 PM   PM User | #3
Raoodo
New to the CF scene

 
Join Date: Dec 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Raoodo is an unknown quantity at this point
This can be classed as now solved. Thankyou
Raoodo is offline   Reply With Quote
Old 12-10-2011, 08:43 PM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,697
Thanks: 5
Thanked 875 Times in 850 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Then edit your first post to select the “solved” prefix from the select box next to the title.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:24 PM.


Advertisement
Log in to turn off these ads.