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

<input type="checkbox" name="live_response" checked>
$("[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.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Vue router Get Current URL in Vue.js Example
  2.   Laravel 5.7 Toggle switch Update DB field using Ajax
  3.   Bootstrap Toggle switch with ajax update to mysql in PHP
  4.   PHP Star Triangle Program printing Source Code
  5.   Laravel Bootstrap Toggle switch Update DB field using Ajax
  6.   Angular 6 Form Validation Tutorial Example From Scratch
  7.   Top 10 MySQL Interview Questions and Answers
  8.   Laravel Ajax Bootstrap Toggle switch Update MySQL
  9.   Bootstrap Toggle switch with ajax update to mysql in Laravel
  10.   Bootstrap Toggle switch Update Database field using Ajax