0

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';
}
2
  • I formatted your code. I had to add }) Commented Apr 4, 2022 at 9:10
  • You are just adding an assignment. You never send that to the server and your code breaks the ajax Commented Apr 4, 2022 at 9:13

1 Answer 1

1

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

someValue : $('#FaturaDurum').is(":checked")
Sign up to request clarification or add additional context in comments.

1 Comment

Not working :((

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.