Fail to load response data jquery.easy-autocomplete.min.js:10 WARNING:

2.5k Views Asked by At

I am using the easyautocomplete, http://easyautocomplete.com/, to populate a list as the user types in a search field. The code is as follows:

var options = {
  url: function(phrase) {
      if (phrase !== "") {
          return "http://<url>/todo?query=" + phrase + "&format=json";
      } else {
          return "http://<url>/todo?query=empty&format=json";
      }
  },

  getValue: "results",

  ajaxSettings: {
      dataType: "jsonp"
  },

  requestDelay: 300,

  theme: "round"
  };

  $("#product-list").easyAutocomplete(options);

I am getting a response from my API that looks like:

{
"results": [
    "list_item_1",
    "list_item_2",
    "list_item_3",
    ...
    "list_item_50"
    ]
}

I have a feeling I'm not formatting the response properly, but I'm not sure how to fix it.

1

There are 1 best solutions below

1
AudioBubble On

A look through the guide it looks like getValue would be if you had an array of objects and wanted to pull a particular key from each one. From the list location section it looks like you are looking for listLocation to specify the object key that has the array of things to autocomplete. So changing getValue to listLocation should give you the results you are looking for