5

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 }
2
  • explain it more details Commented Mar 20, 2014 at 7:21
  • @Dato'MohammadNurdin : Added description pease check. Commented Mar 20, 2014 at 7:29

3 Answers 3

11

There is an invisible char (zero-width space U+200B) after }); in line 37.

I copied your code to my editor

Sign up to request clarification or add additional context in comments.

1 Comment

This is also visible when pasting the code in jsfiddle: jsfiddle.net/Z5ZJL
1

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
}

Comments

-1

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));
    });
};

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.