N
N
Nick Bukovskiy2017-10-10 13:26:28
JSON
Nick Bukovskiy, 2017-10-10 13:26:28

How to output json in Select options?

I am making an ajax request. Passing an array with php "echo json_encode($data);" in js. How can I take the data from this array and output it to options?
I do so

success: function (data) {
                        $.each(data, function(key, val){
                            $('.select-secession').append('<option value="' + val + '">' + val + '</option>');
                        });
                    },

but it only outputs the first option, what's wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question