0

I have this Json data that i would want to pass to JQuery.ui autocomplete

   <input type="text" id="symptom_checker" name="search_symptom" />

JSON encoded data

 var symptoms = [{"symptom_name":"Overall sensation of feeling unwell"},{"symptom_name":"cough"},{"symptom_name":"cough with blood mucus"}];

if i pass it to this function

    $("#symptom_checker").autocomplete({
       source: symptoms
     });

when enter the symptom name it doesn't work, but if i try to use this json data

   var symptoms = ["Overall sensation of feeling unwell", "cough", "cough with blood mucus"]; 

JQUERY

      $("#symptom_checker").autocomplete({
       source: symptoms
     });

It works fine. How do I solve this ?

2
  • Documentation of autocomplete say it should not be a multidimensional array. You should map your json to not multidimensional but you can search in google by 'jquery autocomplete multidimensional array' Commented Nov 30, 2016 at 19:17
  • 1
    Possible duplicate of jQuery UI autocomplete with objects Commented Nov 30, 2016 at 19:18

1 Answer 1

0

As per the documentation it supports two array formats.

  1. Array of Strings
  2. Array of objects with attributes label and value ex: [{label:'' , value:''}]. You can also have only value as attribute.

You have to convert your array into any of these format.

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.