Sanjay Yadav Sanjay Yadav - 2 months ago 16
jQuery Question

Magento Uncaught SyntaxError: Unexpected token <

I am just adding a ticker in my website and using A script in js file . but facing
error Uncaught SyntaxError: Unexpected token <

<![CDATA[<script type="text/javascript">
$(function(){
$('.simple-marquee-container').SimpleMarquee();

});
</script>]]>


Please help me

Answer

You have to remove the <![CDATA[ and ]]>. Or put it on the inside of script, with // in front, as a comment.

<script type="text/javascript">
$(function() {
    $('.simple-marquee-container').SimpleMarquee();
});
</script>

or

<script type="text/javascript">
//<![CDATA[
$(function() {
    $('.simple-marquee-container').SimpleMarquee();
});
//]]>
</script>

See also, when and why CDATA is needed.