Nahser Bakht
Nahser Bakht

Reputation: 930

jQuery error. When I degug in firebug I get this error:

my code:

var custID = <?php echo htmlentities( $_GET['custID'] ); ?>;

I get error in firebug:

SyntaxError: syntax error [Break On This Error]       var custID = <br />

Please note: I am not passing a parameter custID.

Upvotes: 0

Views: 77

Answers (1)

BenM
BenM

Reputation: 53198

You need to specify it as a string, if using htmlentities():

var custID = '<?php echo htmlentities( $_GET['custID'] ); ?>';

It is also worth noting that you might need to add slashes to the string to prevent it from breaking out of the literal in JS:

var custID = '<?php echo addslashes(htmlentities( $_GET['custID'] )); ?>';

Upvotes: 2

Related Questions