[Answer]-Google Chrome: SyntaxError: Unexpected end of input

1👍

You need a ; at the end of this:

$.ajax({
            type: 'GET',
            url: '{% url "search.views.search" inputString="xyz" %}'.replace("xyz", inputString.toString()),
            dataType: 'json',
                success: function(search_results){
            suggestions = JSON.parse(JSON.stringify(search_results));
                        alert(suggestions[0].name);

                    }
                });

0👍

same conclusion 🙂

you missed a semicolon ;

jslint could help you to find this kind of errors : http://www.jslint.com/

function lookup(inputString) {
  if (inputString.length === 0) {
    $('#suggestions').empty().fadeOut();
  }
  else {
    $.ajax({
      type: 'GET',
      url: '{% url "search.views.search" inputString="xyz" %}'.replace("xyz", inputString.toString()),
      dataType: 'json',
      success: function(search_results) {
        suggestions = JSON.parse(JSON.stringify(search_results));
        alert(suggestions[0].name);
      }
    });
  }
}
👤Shipow

Leave a comment