Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | 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
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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..... :)

Reply With Quote
  #2 (permalink)  
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
Reply With Quote
  #3 (permalink)  
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.

Reply With Quote
  #4 (permalink)  
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
Reply With Quote
  #5 (permalink)  
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.

Reply With Quote
  #6 (permalink)  
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. :)

Reply With Quote
  #7 (permalink)  
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
Reply With Quote
  #8 (permalink)  
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....:)

Reply With Quote
  #9 (permalink)  
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

:(

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:01 PM.


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