PDA

View Full Version : Ajax XML Ticker & junk after document elem



shawn@TheUnixMasters.com
01-16-2010, 07:35 PM
Is there any way to get rid of the following error:
junk after document element
...
<div class="message">
^
Ajax XML Ticker can be executed at:
http://www.dynamicdrive.com/dynamicindex2/ajaxticker.htm

Thank you.

jscheuer1
01-17-2010, 06:41 PM
Yes. Instead of following the exact syntax for your external text file, use this template (additions highlighted):


<!-- Wrap each ticker cotent inside <div class="message"> tag -->
<div>
<div class="message">
<a href="http://www.javascriptkit.com" target="_new">JavaScript Kit</a><br />Comprehensive JavaScript tutorials and over 400+ free scripts!
</div>

<div class="message">
<a href="http://www.codingforums.com">Coding Forums</a><br />Web coding and development forums.
</div>

<div class="message">
<a href="http://www.cssdrive.com">CSS Drive</a><br />Categorized CSS gallery and examples.
</div>

<div class="message">
<a href="http://www.javascriptkit.com/domref/">DOM Reference</a><br />This is a no-nonsense, easy to follow DOM reference for JavaScript.
</div>
</div>

ddadmin
01-17-2010, 11:11 PM
Interesting John, can you explain why that fixes the error?

jscheuer1
01-18-2010, 06:01 AM
I'm thinking it's most likely as the error itself tends to indicate. Firefox, possibly others, not IE (which gives no error because it sees the response text as text only) report this as like:


junk after document element

So I thought, what document? It's an xml document right? Well an xml document must have an overall opening and closing tag. In xml it doesn't matter what the tag is. Tags in xml may be user defined. But since we are importing this to an HTML document, may as well use a tag that will be valid there as well.

Without an overall opening and closing tag, Firefox sees the first tag as the entire document, with the other div tags as "junk".