'Getting checkbox value with js and ajax

According to the checkbox information I received from the frontend, I will record to the database in the backend. I am stuck in the part where I wrote not working as expected, please help.

Frontend;

$.ajax({
  url: '{{ route('diffacts.manage.confirm.process ') }}?a=e&id=' + data.id,
  method: 'GET',
  data: {
    date_start: $('#date_start').val(),
    duration: $('#duration').val(),
    operation_type_id: $('#diffact_type_id').val(),
    description: $('#description').val(),
    // the if / else not working as expected
    if ($('#FaturaDurum').is(":checked")) {
      document.getElementById('FaturaDurum').value = "1"
    } else {
      document.getElementById('FaturaDurum').value = "0"
    }
    FaturaDurum: $('#FaturaDurum').val()
  }
})

Backend;

if($request->input('FaturaDurum') == "1") {
  $faturadurum = 'Faturalandirilmamis';
}
else {
  $faturadurum = 'Faturalandirilmis';
}


Solution 1:[1]

I think it's better to write the code like this:

someValue : $('#FaturaDurum').is(":checked")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mplungjan