MethodNotAllowedHttpException使用jQuery追加时

时间:2015-08-27 05:56:19

标签: jquery laravel-5

我不知道为什么我会收到此错误,当我点击按钮将某些html附加到视图时会输出此错误...

这是我的路线

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

Controller返回一个视图,其中包含从数据库中获取的一些参数。 以下是观点:

<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 >

这是我在#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');
        }
    });
});

有人能解释我为什么会发生这种错误吗?我的意思是,我没有看到任何错误!我不知道的是它是否与页面重新加载有关。 ..&#39;

更新1

问题是路由错误,我试图发布到get路由...现在的问题是它重新加载页面以便元素没有附加,我怎么能解决这个问题,也许是ajax?如果是这样,怎么样?

0 个答案:

没有答案