Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional Ajax ISBN: 978-0-471-77778-6
This is the forum to discuss the Wrox book Professional Ajax by Nicholas C. Zakas, Jeremy McPeak, Joe Fawcett; ISBN: 9780471777786
Important: For the new 2nd edition of this book, please post here instead: [url="http://p2p.wrox.com/forum.asp?FORUM_ID=307"]http://p2p.wrox.com/forum.asp?FORUM_ID=307[/url]
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Ajax ISBN: 978-0-471-77778-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 17th, 2006, 09:59 AM
Registered User
 
Join Date: Apr 2006
Location: Fortson, GA, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dangerduck Send a message via Yahoo to dangerduck
Default News Ticker

I am trying to complete the NewsTicker widget. I'm writing newsticker.js right i even downloaded the code and it still will not work.

Code:
if ( isset( $_GET["http://www.ledger-enquirer.com/mld/ledgerenquirer/news/breaking_news/rss.xml"] ) ) {

    $remoteUrl = $_GET["http://www.ledger-enquirer.com/mld/ledgerenquirer/news/breaking_news/rss.xml"];

    $xml = file_get_contents($remoteUrl);


That is the url that the feed i want is located. The following is the include section of the default.htm file:
Code:
    <link rel="stylesheet" type="text/css" href="css/newsticker.css" />
    <script type="text/javascript" src="js/zxml.js"></script>
    <script type="text/javascript" src="js/xparser.js"></script>
    <script type="text/javascript" src="js/newsticker.js"></script>
    <script type="text/javascript">
    function init() {
        var newsTicker = new NewsTicker();    
        newsTicker.add("http://www.ledger-enquirer.com/mld/ledgerenquirer/news/breaking_news/rss.xml");        
    }

    onload = init;


And this is my newsticker.js Xparser initiation:

Code:
NewsTickerFeed.prototype.populateTicker = function (sXml) {
    var oParser = new XParser("http://www.ledger-enquirer.com/mld/ledgerenquirer/news/breaking_news/rss.xml", true);

    var spanLinkContainer = document.createElement("span");

    var aFeedTitle = document.createElement("a");
    aFeedTitle.className = "newsTicker-feedTitle";
    aFeedTitle.href = oParser.link.value;
    aFeedTitle.target = "_new";
    aFeedTitle.innerHTML = oParser.title.value;


    spanLinkContainer.appendChild(aFeedTitle);

    for (var i = 0; i < oParser.items.length; i++) {
        var item = oParser.items[i];

        var aFeedLink = document.createElement("a");
        aFeedLink.href = item.link.value;
        aFeedLink.target = "_new";
        aFeedLink.className = "newsTicker-feedItem";
        aFeedLink.innerHTML = item.title.value;

        spanLinkContainer.appendChild(aFeedLink);
    }


You can see the javascript errors at this url. http://www.thrivenews.com/NewsTicker/
I'm getting 2 errors right now. one is "Xparser is not defined" the other is in the php "no element found"...

Please, I would love any help..... :)

 
Old April 17th, 2006, 10:17 AM
jmcpeak's Avatar
Wrox Author
Points: 467, Level: 7
Points: 467, Level: 7 Points: 467, Level: 7 Points: 467, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 87
Thanks: 0
Thanked 18 Times in 17 Posts
Default

[Edit] Writing reply =)

------------------------
Jeremy McPeak
Author, Professional Ajax
http://www.wdonline.com
 
Old April 17th, 2006, 12:48 PM
Registered User
 
Join Date: Apr 2006
Location: Fortson, GA, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dangerduck Send a message via Yahoo to dangerduck
Default

Cool thanks I really want to see what is wrong. :) I have been working on this of and on for 3 weeks.

 
Old April 18th, 2006, 08:37 AM
jmcpeak's Avatar
Wrox Author
Points: 467, Level: 7
Points: 467, Level: 7 Points: 467, Level: 7 Points: 467, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 87
Thanks: 0
Thanked 18 Times in 17 Posts
Default

I'm at work; therefore, I cannot access your web site (network Nazis). I can, though, comment on the code you've posted. =)

The main thing I see are the changes you've made to the code. From what I'm seeing, they are unnecessary changes. The widget is designed to pick up any RSS/Atom feed, so all you have to do is create a NewsTicker object and add a feed:
Code:
var myNewsTicker = new NewsTicker();

myNewsTicker.add("http://www.ledger-enquirer.com/mld/ledgerenquirer/news/breaking_news/rss.xml");
That should get it working for you.


------------------------
Jeremy McPeak
Author, Professional Ajax
http://www.wdonline.com
 
Old April 18th, 2006, 11:05 AM
Registered User
 
Join Date: Apr 2006
Location: Fortson, GA, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dangerduck Send a message via Yahoo to dangerduck
Default

Thanks I'll give this a try and let you know how it goes.

 
Old April 18th, 2006, 11:20 AM
Registered User
 
Join Date: Apr 2006
Location: Fortson, GA, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dangerduck Send a message via Yahoo to dangerduck
Default

I did what you suggested And I'm getting a new javascript error now.

Error: oToAppend has no properties
Source File: http://www.thrivenews.com/NewsTicker/js/newsticker.js
Line: 22

And that is an unmodified version of the newsticker.js file. I just pulled it off the site.

Here is the code for the html page that I'm testing the ticker on.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Ajax News Ticker</title>
    <link rel="stylesheet" type="text/css" href="css/newsticker.css" />
    <script type="text/javascript" src="js/zxml.js"></script>
    <script type="text/javascript" src="js/xparser.js"></script>
    <script type="text/javascript" src="js/newsticker.js"></script>
    <script type="text/javascript">
    var myNewsTicker = new NewsTicker();
        myNewsTicker.add("http://www.ledger-enquirer.com/mld/ledgerenquirer/news/breaking_news/rss.xml");
    </script>
</head>    
<body>
</body>
</html>
I would love some help... Thanks for helping me get this down to one error. :)

 
Old April 19th, 2006, 12:09 PM
jmcpeak's Avatar
Wrox Author
Points: 467, Level: 7
Points: 467, Level: 7 Points: 467, Level: 7 Points: 467, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 87
Thanks: 0
Thanked 18 Times in 17 Posts
Default

The creation of a NewsTicker object much take place when the page loads. This is a necessity because the HTML elements created by the NewsTicker is appended to either the document's body, or the supplied HTMLElement passed to the constructor. Running the script when the page loads ensures the document is completely loaded, and the HTML elements can be appended to the document. Otherwise, an error is thrown (the one you're seeing) stating that the element doesn't exist.

------------------------
Jeremy McPeak
Author, Professional Ajax
http://www.wdonline.com
 
Old April 20th, 2006, 05:50 AM
Registered User
 
Join Date: Apr 2006
Location: Fortson, GA, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dangerduck Send a message via Yahoo to dangerduck
Default

Ok I'm getting no errors now I stuck that myNewsticker into a function. But it's still not working. And I have now errors.

Code:
 
<link rel="stylesheet" type="text/css" href="css/newsticker.css" />
    <script type="text/javascript" src="js/zxml.js"></script>
    <script type="text/javascript" src="js/xparser.js"></script>
    <script type="text/javascript" src="js/newsticker.js"></script>

    <script type="text/javascript">
    function init(){
    var myNewsTicker = new NewsTicker();
        myNewsTicker.add("http://www.ledger-enquirer.com/mld/ledgerenquirer/news/breaking_news/rss.xml");
    }
    </script>
This is a new feat though no errors. I guess I could go try it in IE havent done that but I doubt it will work. Thanks for all your help and if you have any more please feel free....:)

 
Old April 21st, 2006, 07:09 AM
Registered User
 
Join Date: Apr 2006
Location: Fortson, GA, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dangerduck Send a message via Yahoo to dangerduck
Default

Now I'm getting another js error

XParser not defined

:(





Similar Threads
Thread Thread Starter Forum Replies Last Post
Separating news from the articles and add news pic Isaak BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 December 12th, 2006 11:25 AM
using javascript ticker in asp.net vivek_inos ASP.NET 1.0 and 1.1 Professional 1 June 5th, 2006 12:05 PM
news ticker functionality badgolfer Classic ASP Basics 1 October 15th, 2004 12:37 AM
news ticker badgolfer ASP.NET 1.0 and 1.1 Basics 0 October 13th, 2004 03:34 AM
problem with News Ticker Application benito BOOK: ASP.NET Website Programming Problem-Design-Solution 2 September 1st, 2004 03:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.