复选框ajax数据

I have check box and want send value check box (0 or 1) and in entity where clicked check box on some action

        <input class="searchType" type="checkbox" name="SharingNotification" id={{ taskExecution.id }}>
        <label class="searchtype2label">{{ taskExecution.id }}</label>
    </input>


$('.searchType').click(function(event) {
    if(this.checked){
        $.ajax({
            type: "POST",
            url: '/app_dev.php/api/customer/customers',
            data: {
                id: event.target.id,
                value: event.target.value
            },,
            success: function(data) {
                alert('it worked');
                alert(data);
                $('#container').html(data);
            },
            error: function() {
                alert('it broke');
            },
            complete: function() {
                alert('it completed');
            }
        });

    }
});

in request in action

request = {Symfony\Component\HttpFoundation\ParameterBag} [1]
 parameters = {array} [2]
  id = "1"
  value = "on"

I try like this

event.target.id
"1"
event.target.value
"on"

but why "on" I think can be 1 or 0

how to send data like key(id entity) => value(value check box) ?

In this case you should use a dictionary and send it to code-behind.

var dictionary= {};
dictionary[$(this).attr('id')] = $(this).is(":checked")==true? 1:0;

And pass it to ajax data like this:

data:dictionary

You can create the object to send like this :

var objToSend = {};
objToSend[$(this).attr('id')] = $(this).is(":checked");

And send your data like

data: objToSend