Jump to content

Uncaught SyntaxError: Unexpected token )


tascam424

Recommended Posts

Hi folks, i'm trying desperately to convert an HTML template to a Smarty Template for WHMCS, everything is going fine except i can't get the Parallax Slider to function.

 

It works perfectly in the standard HTML Template but won't work in the Smarty Template, so i'm guessing some of the core WHMCS scripting must be conflicting.

 

The only thing i can see is          Uncaught SyntaxError: Unexpected token )    ultrawebtemplates.com/ :94

 

Lines 94 - 106 look like this 

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
		<script type="text/javascript" src="templates/Custom/js/jquery.cslider.js"></script>
		<script type="text/javascript">
			$(function() {
			
				$('#da-slider').cslider({
					autoplay	: true,
					bgincrement	: 450
				});
			
			});
		</script>	

Off course if anybody would care to look you can see the live domain http://ultrawebtemplates.com

 

Greatly appreciate any help.

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/285966-uncaught-syntaxerror-unexpected-token/
Share on other sites

Surround your script tags with smarty's {literal}...{/literal} tags What's happening is smarty is treating the { and } in the script as smarty tags and replacing them. If you view-source on your page you will see that the code is actually:

		<script type="text/javascript">
			$(function() );
			
			});
		</script>

Have you ever been told how wonderful you are ?

 

Thank you so very much !!

 

Worked perfectly just by adding that to the little piece of script. Is it necessary to do that when calling a script library also ?

 

Like this <script type="text/javascript" src="templates/Custom/js/jquery.cslider.js"></script>

 

It wasn't required in this circumstance but it it best practice ?

 

Thank you again !!

Is it necessary to do that when calling a script library also ?

No, the script tags importing external files do not contain any { } pairs so they are not affected by smarty. Neither are the external files referenced as they are not parsed by smarty.

 

Online inline scripts (or anywhere else you use { } pairs) needs to be wrapped in the literal tags.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.