What does selectize expect as a return in order to load a select

239 views Asked by At

I have a normal ajax call that is working correctly. I have tried passing data back multiple ways. What is selectize expecting in order to populate the select?

kick_subset.load(function(callback) {

                xhr && xhr.abort();
                    xhr = $.ajax({
                    url: 'ajax/selectize.php',
                    dataType: 'json',
                    data:({client: value}),
                    success: function(results) {
                        kick_subset.enable();
                        callback(results);
                    },
                    error: function() {
                        callback();
                    }
                    })
                    });
1

There are 1 answers

0
Mrd05d On BEST ANSWER

So it took me a while but i finally figured it out. It looks for the following format:

[{"id":0,"value":"one"},{"id":1,"value":"two"}]

I did the following to test/make it work:

$one = array("id" => 0, "value" => "one");
$two = array("id" => 1, "value" => "two");

$subsets = array($one,$two);
echo json_encode($subsets);