Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
103
rated 0 times [  108] [ 5]  / answers: 1 / hits: 28211  / 11 Years ago, sun, december 22, 2013, 12:00:00

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]='<?php echo get_bloginfo('url'); ?>';
paramdata[1]= $('#'+sel_id).val();

var to_shortlist=false;
var url='<?php echo bloginfo('url'); ?>/wp-admin/admin-ajax.php';

if($('#'+sel_id).attr('checked')){
$(#alert_titleid).empty().html('Adding to Shortlist');
$(#alert_msgid).empty().html('loading...');
display_alert();
var rqpage='add to shortlist';

var arr_dataval = {
action: 'instinct_controller',
rqpage:rqpage,paramdata:paramdata
};

$.post(ajaxurl,arr_dataval ,function(data){
$(#alert_msgid).empty().html(data);
});

}else{
$(#alert_titleid).empty().html('Removing from Shortlist');
$(#alert_msgid).empty().html('loading...');
display_alert();
var rqpage='remove from shortlist';
var arr_dataval = {
action: 'instinct_controller',
rqpage:rqpage,
paramdata:paramdata
};
$.post(ajaxurl,arr_dataval ,function(data){
$(#alert_msgid).empty().html(data);
});
}
}

More From » jquery

 Answers
6

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



paramdata[0]='<?php echo 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]='<?php echo get_bloginfo('url'); ?>';


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



Same thing in the following line:



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

[#73611] Friday, December 20, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brendan

Total Points: 426
Total Questions: 110
Total Answers: 94

Location: Western Sahara
Member since Mon, May 3, 2021
3 Years ago
;