mercredi 6 novembre 2019

ajax request shown 404 not found in laravel

In laravel I am trying to update master slide onclick of checkbox using ajax request. but every time it shown 404 not found. what i did wrong i am not understand. please help.    
    here is my view

        <div class="form-group margin-top-10 radio-btn styleThese">
                            <label>
                                {!! Form::checkbox('master_slide', $community->master_slide,null, array('id'=>'master_slide', 'class'=>'community-update', 'url' => 'master')) !!}
                                <span  style=" display: inline-block;"> Allow Master Slides in Digital Display
                                </span>
                            </label>
                        </div>

I am trying to update master slide onclick of checkbox. but every time it shown 404 not found. what i did wrong i am not understand. please help.

    here is js
    $(document).ready(function(){

        $(document).on("click", ".community-update", function() {
             var $form = $(this);
             //console.log($form);
             //url = 'master';
            //console.log(url);
            url = $form.attr('url');
            //console.log(url);


            $.ajax({
                url: url,
                type: 'POST',
                data:{

                    master_slide: $('#master_slide').val(),

                },
                success: function(dataResult){
                    alert('saved');

                }
            });
        });
    });

I am trying to update master slide onclick of checkbox. but every time it shown 404 not found. what i did wron i am not understand. please help. here is my controller

    public function masterupdate(Community $community, CreateCommunityRequest $request,$id)
        {
            $data = Community::where('id', session('communityId'))->first();
            //dd($data);

            if (!isset($data['master_slide'])) {
                $data['master_slide'] = 0;
            }
            $community->update($data);

            echo "1";


        }

    here is my route 
     Route::post('communities/master', 'CommunitiesController@masterupdate')->name('master');


I am trying to update master slide onclick of checkbox. but every time it shown 404 not found. what i did wron i am not understand. please help.


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire