Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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 01:34 PM. Reason: wrapped code tags

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,877
    Thanks
    6
    Thanked 1,035 Times in 1,008 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This can be classed as now solved. Thankyou

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,877
    Thanks
    6
    Thanked 1,035 Times in 1,008 Posts
    Then edit your first post to select the “solved” prefix from the select box next to the title.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •