For some reason, I'm getting this error message:
Uncaught SyntaxError: Unexpected token <
For this line of code:
title: '<img src="/images/text/text_mario_planet_jukebox.png" id="text_mario_planet_jukebox"/>',
In this context:
$(document).ready(function() { $('#infobutton').click(function() { $('#music_descrip').dialog('open'); }); $('#music_descrip').dialog({ title: '<img src="/images/text/text_mario_planet_jukebox.png" id="text_mario_planet_jukebox"/>', autoOpen: false, height: 375, width: 500, modal: true, resizable: false, buttons: { 'Without Music': function() { $(this).dialog('close'); $.cookie('autoPlay', 'no', { expires: 365 * 10 }); }, 'With Music': function() { $(this).dialog('close'); $.cookie('autoPlay', 'yes', { expires: 365 * 10 }); } } }); });
I think everything should be good to go, but I don't understand why the <
is somehow throwing this off..
whoops, forgot to show where this is happening! My bad,
http://www.marioplanet.com/index.asp
Any ideas?
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided. This might be a simple typo.
The 'Uncaught SyntaxError: Unexpected token u in JSON at position 0' error is caused when the client has been asked to execute JSON. parse() on a string beginning with u instead of the stringified object it was expecting. Usually this is a stringified version of the undefined primitive.
This is a browser issue rather than a javascript or JQuery issue; it's attempting to interpret the angle bracket as an HTML tag.
Try doing this when setting up your javascripts:
<script> //<![CDATA[ // insert teh codez //]]> </script>
Alternatively, move your javascript to a separate file.
Edit: Ahh.. with that link I've tracked it down. What I said was the issue wasn't the issue at all. this is the issue, stripped from the website:
<script type="text/javascript" $(document).ready(function() { $('#infobutton').click(function() { $('#music_descrip').dialog('open'); }); $('#music_descrip').dialog({ title: '<img src="/images/text/text_mario_planet_jukebox.png" id="text_mario_planet_jukebox"/>', autoOpen: false, height: 375, width: 500, modal: true, resizable: false, buttons: { 'Without Music': function() { $(this).dialog('close'); $.cookie('autoPlay', 'no', { expires: 365 * 10 }); }, 'With Music': function() { $(this).dialog('close'); $.cookie('autoPlay', 'yes', { expires: 365 * 10 }); } } }); });
Can you spot the error? It's in the first line: the <script
tag isn't closed. It should be <script type="text/javascript">
My previous suggestion still stands, however: you should enclose intra-tagged scripts in a CDATA block, or move them to a separately linked file.
That wasn't the issue here, but it would have shown the real issue faster.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With