“Defina as opções usando o jQuery in Laravel Form Collective” Respostas de código

Defina as opções usando o jQuery in Laravel Form Collective

<script>
    $(document).ready(function() {

            //Make an Ajax request to a Laravel route
            //This will return the data that we can add to our Select element.
            $.ajax({
                url: 'YOUR URL GOES HERE',
                type: 'get',
                success: function(data){

                    //Log the data to the console so that
                    //you can get a better view of what the script is returning.
                    console.log(data);

                    $.each(data, function(key, value){
                        //Use the Option() constructor to create a new HTMLOptionElement.
                        var option = new Option(key, value);
                        //Convert the HTMLOptionElement into a JQuery object that can be used with the append method.
                        $(option).html(value);
                        //Append the option to our Select element.
                        $("#job").append(option);
                    });

                }
            });

        });
</script>
Nervous Narwhal

Defina as opções usando o jQuery in Laravel Form Collective

//...
{!! Form::select('jobsList[]', [], null, ['id' => 'job', 'class' => 'form-control' 'multiple', 'style' => 'width: 60%; margin-top: 10px;', 'disabled'=>'disabled']) !!}
..//
Nervous Narwhal

Respostas semelhantes a “Defina as opções usando o jQuery in Laravel Form Collective”

Perguntas semelhantes a “Defina as opções usando o jQuery in Laravel Form Collective”

Mais respostas relacionadas para “Defina as opções usando o jQuery in Laravel Form Collective” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código