Reputation:
Here is my javascript code, I'm getting error Uncaught SyntaxError: Unexpected token ILLEGAL at Line no 37
I was trying to append the options to "select" list from a json, my code seems to be have no syntax error. but chrome is throwing one.
31 set_options_list = function(selctelm, json){
32 $(selctelm).empty();
33 $.each(json, function(k, val) {
34 $(selctelm).append(
35 $("<option></option>").text(val).val(val)
36 )
37 });
38 }
Upvotes: 5
Views: 114
Reputation: 23911
I found out your code missing some tag.
set_options_list = function(selctelm, json) {
$(selctelm).empty();
$.each(json, function(k, val) {
$(selctelm).append(
$("<option></option>").text(val).val(val));
});
};
Upvotes: -1
Reputation: 160963
There is an invisible char (zero-width space U+200B) after });
in line 37.
Upvotes: 11
Reputation: 20428
Remove illigeal character
Try this Jquery;
set_options_list = function(selctelm, json){
$(selctelm).empty();
$.each(json, function(k, val) {
$(selctelm).append($("<option></option>").text(val).val(val)); // Here semicolon
});//Here there is illegal character
}
Upvotes: 1