mercredi 26 août 2015

MethodNotAllowedHttpException When using jQuery append

I don't know why i get this error, when i hit a button to append some html to the view it outputs this error...

This is my route

Route::get('/reservacion', [
    'as' => 'publicReservacion',
    'uses' => 'ReservacionCtrl@inicio'
]);

The Controller returns a view with some parameters taken from a database. Here's the view:

<div class = "col-md-12 wow fadeInLeft" >
    <header class = " section-title" >
        <h2 ><span >Formulario</span > online</h2 >
        </header >
        <br >

        <br >
        {!! Form::open(['url'=>'reservacion','autocomplete'=>'on']) !!}
        <fieldset >
            {!! Form::label('seleccionecomidas', 'Seleccione los platillos que desea reservar ',['for' => 'comidas']) !!}
            <br ><br ><br >
            <div id="comidas" class="owl-carousel owl-theme">
                @foreach($platos as $plato)
                <a class="item opcion" >
                    <img class="img" src = "{{ asset('club/img/gallery/gallery1.jpg') }}" alt = "{{ $plato->nombre }}" >
                </a >
                @endforeach
            </div>

            <br ><br ><br >

            {!! Form::label('seleccionebebidas', 'Seleccione las bebidas que desea reservar ',['for' => 'bebidas']) !!}
            <br ><br ><br >
            <div id="bebidas" class="owl-carousel owl-theme">
                @foreach($bebidas as $bebida)
                {{--{{ dd($plato) }}--}}
                <a class="item opcion" >
                    <img class="img" src = "{{ asset('club/img/gallery/gallery2.jpg') }}" alt = "{{ $bebida->nombre }}" >
                </a >
                @endforeach
            </div>
            <br ><br >
            <button id="completarseleccion">Agregar</button>
            <br ><br ><br >
            {!! Form::label('opcioneseleccionadas', 'Opciones seleccionadas',['for' => 'seleccionados']) !!}
            <div id="menuseleccionado" class="owl-carousel owl-theme">

            </div>
            <br ><br ><br >

            <div id="seleccionados" class="owl-carousel owl-theme">
                <a class="item opcion" >
                    <img class="img" src = "{{ asset('club/img/gallery/gallery3.jpg') }}" alt = "Nada Seleccionado" >
                </a >
            </div>
            <br ><br ><br >
            <div class = "input-container col-md-12" >
                {!! Form::label('cantidadpersonas', 'Cantidad de personas',['for' => 'personas']) !!}
                {!! Form::text('personas', null, ['placeholder'=>'ej. 4']) !!}
            </div >
            <!-- /input-container -->
            <div class = "input-container  col-md-12" >
                <div class = "form-group" >
                    {!! Form::label('fechasolicitud', 'Fecha ',['for' => 'fechaInicio']) !!}
                    {!! Form::date('fechaInicio',\Carbon\Carbon::now(), array('class'=>'text-center')) !!}
                </div >
            </div >
            <div class = "input-container col-md-12" >
                {!! Form::textarea('detalles', null, ['size' => '30x5', 'placeholder'=>'Mensaje', 'rows'=>'5']) !!}
            </div >
            <!-- /input-container -->
            <div class = "input-container col-md-12 " >
                <button type = "submit" class = "custom-button button-style1 text-center" ><i ></i >Enviar
                </button >
            </div >
            <!-- /input-container -->
        </fieldset >
        {!! Form::close() !!}
    </div >

And this is the function where i append the elements inside #completarseleccion:

$("#completarseleccion").click(function(){
            var btn_element = $(this);
            //this is how you loop through your item and add it to a specific element
            $(".opcion").each(function(){
                if($(this).hasClass("clicked")){
                    $($(this).html()).append('#menuseleccionado');
                }
            });
        });

Could anyone explain me why this error happens?, i mean, there's nothing i can see that is wrong!, what i don't know is if it has something to do with the page reload...



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1LCnmpp
via IFTTT

Aucun commentaire:

Enregistrer un commentaire