Skip to content Skip to sidebar Skip to footer

Javascript Error - Uncaught Syntaxerror: Unexpected Identifier

I am getting a 'Uncaught SyntaxError: Unexpected identifier' on the code below on line 3 in Chrome function popup_shortlist(sel_id){ var paramdata=Array(); paramdata[0]='

Solution 1:

You have a syntax error, depending on what you want to do this line should be

paramdata[0]='<?phpecho get_bloginfo(' + url + '); ?>';

or if you want to send the string 'url' to the get_bloginfo function you have to escape the single quotes

paramdata[0]='<?phpecho get_bloginfo(\'url\'); ?>';

my guess is that you want to do the first one.

Same thing in the following line:

var url='<?phpecho bloginfo(' + url + '); ?>/wp-admin/admin-ajax.php';

Solution 2:

Looks like you want paramdata[0] to be a straight string, no concatenation involved? In that case, use double quotes on the outside, or it treats the single quotes around 'url' as ending a string and looks for a + or a ;.

function popup_shortlist(sel_id){
    var paramdata=Array();  
        paramdata[0]="<?phpecho get_bloginfo('url'); ?>";

Post a Comment for "Javascript Error - Uncaught Syntaxerror: Unexpected Identifier"