Toggle Switches Laravel, Ajax and jQuery example

Today, We want to share with you Toggle Switches Laravel, Ajax and jQuery example.In this post we will show you Multiple JQuery Toggle Buttons with on off events in Laravel 5.7, hear for store value from on/off button in mysql database using Laravel ajax we will give you demo and example for implement.In this post, we will learn about JQuery/AJAX Toggle Switch POST to Laravel file without navigation with an example.

Toggle Switches Laravel, Ajax and jQuery example

There are the Following The simple About Toggle Switches Laravel, Ajax and jQuery example Full Information With Example and source code.

As I will cover this Post with live Working example to develop Create Radio Button Toggle Switch with Bootstrap and Laravel, so the Bootstrap Toggle switch with ajax update to mysql in Laravel 5.7 for this example is following below.

Laravel switchClass and toggleClass in jQuery

HTML Part for store value from on/off button in mysql database using Laravel ajax


$("[name='live_response']").bootstrapSwitch('state');

JavaScript Source Code

$("[name='live_response']").bootstrapSwitch();
$(document).ready(function() {
    $("[name='live_response']").on('switchChange.bootstrapSwitch',function(){
        var mode_value = $(this).attr("value");
        var station = $(this).attr("id");
        $.ajax({
            url: 'statusUpdate',
            method: 'post',
            data: {id: mode_value, _token: $('input[name="_token"]').val(), reply_flag: mode_value, station: station},
            success: function(data){
                alert("Auto Canneded Response has been Turned On");
            },
            error: function(){}
        });
    });
});

Laravel Controller method

public function statusUpdate()
    {
        $data = Input::all();

        if(Request::ajax())
        {
            $station = Input::get('station');
            $live_response = AutoReply::where('station', $station)->all();
            $live_response->reply_flag = $data['reply_flag'];
            $live_response->update();
        }
    }

Example 2: Laravel Bootstrap Toggle switch

Laravel Bootstrap Toggle switch Update DB field using Ajax

Example 3: Laravel 5.7 Toggle switch

Laravel 5.7 Toggle switch Update DB field using Ajax

Example 4: Toggle Switch Inside Bootstrap Laravel

Laravel Toggle Switch Inside Bootstrap Ajax Example

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Toggle Switches Laravel, Ajax and jQuery example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment