|
|
 |
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

April 17th, 2006, 10:59 AM
|
|
Registered User
|
|
Join Date: Apr 2006
Location: Fortson, GA, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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..... :)
|

April 17th, 2006, 11:17 AM
|
 |
Wrox Author
|
|
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 33
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
[Edit] Writing reply =)
------------------------
Jeremy McPeak
Author, Professional Ajax
http://www.wdonline.com
|

April 17th, 2006, 01:48 PM
|
|
Registered User
|
|
Join Date: Apr 2006
Location: Fortson, GA, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Cool thanks I really want to see what is wrong. :) I have been working on this of and on for 3 weeks.
|

April 18th, 2006, 09:37 AM
|
 |
Wrox Author
|
|
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 33
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
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
|

April 18th, 2006, 12:05 PM
|
|
Registered User
|
|
Join Date: Apr 2006
Location: Fortson, GA, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks I'll give this a try and let you know how it goes.
|

April 18th, 2006, 12:20 PM
|
|
Registered User
|
|
Join Date: Apr 2006
Location: Fortson, GA, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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. :)
|

April 19th, 2006, 01:09 PM
|
 |
Wrox Author
|
|
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 33
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
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
|

April 20th, 2006, 06:50 AM
|
|
Registered User
|
|
Join Date: Apr 2006
Location: Fortson, GA, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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....:)
|

April 21st, 2006, 08:09 AM
|
|
Registered User
|
|
Join Date: Apr 2006
Location: Fortson, GA, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Now I'm getting another js error
XParser not defined
:(
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |