Options Selectize.js using Ajax

0

I'm developing an application using selectize.js, and would like the values that appear in the input or select to be imported from the BD (Mysql). I would like to import them using ajax, because when selecting an option in select, other fields must be filled in automatically. Example of the code I'm creating to make it easier to understand:

<input type="text" id="produtos">
<input type="text" id="valor">


       <script>
           $('#produtos').selectize({
               options:[
                   {value:1,name:"teste"},
                   {value:2,name:"teste 2"},
                   ],
               labelField:'name',
               searchField:['name'],
               placeholder:"Entre com um nome",
               delimiter:",",
               create:false,
               openOnFocus:false,

           });

       </script>

I want the options to be imported from the DB, and when I fill in the first input, the second one is automatically populated.

Obs: selectize imports are all correct and working. And I'm using codeigniter.

Thank you in advance!

    
asked by anonymous 03.05.2018 / 16:39

0 answers