lundi 24 octobre 2016

Laravel - Toggle value in database with checkbox and ajax

I want to toggle a boolean value in my table with a checkbox through jquery and ajax.

So whenever a user ticks the the checkbox it should toggle the value in table.

So far i came up with this but i need help:

$(document).ready(function(){
        $("input:checkbox").change(function() { 
            var isChecked = $("input:checkbox").is(":checked") ? 1:0; 
            $.ajax({
                type:'POST',
                url:'/activation',
                headers: {'X-CSRF-TOKEN': '' },
                data: $('.checkbox').serialize(),
                    success:function(data){

                    }
            });
        });
    });




Aucun commentaire:

Enregistrer un commentaire