0

I have the following json

[{"ActionScript":"orange"},{"AppleScript":"orange"},{"Asp":"red"}]

and I'd like jquery autocomplete to use that response from an ajax request.

The name of the language is the search term but the value is the colour of the tag i want to append to a html element elsewhere.

This is me trying to figure it out

  $("#tags").autocomplete({
    source: function(request, response){
      $.get("/tickets/tags.json", {data:request.term}, function(data){
        $(data).each(function(index, value){
          console.log(index); // this a number
          console.log(data[index]); // this returns an object like Scala:"green"
        });
      },"json");
    }
  });   
Joseph Le Brech
  • 6,541
  • 11
  • 49
  • 84

0 Answers0