带有FormData.Append的复选框

I am using Javascript FormData.Append to pass values to a php file, but I cannot get check boxes working. For Example

HTML

<input type="checkbox" name="XXX" value="XXX" /><label>XXX Option</label>

JS

FormData.append( 'XXX', $('input[name=XXX]').val());

PHP

if (isset($_POST['XXX'])) {    echo "checked!";}

Whether I check the box or not, I get the response - checked!

OR PHP

$XXX= $_POST['XXX'];

The var $XXX shows value XXX whether checked or not.

How can I pass checkboxes using this method so I can differentiate if the checkbox is ticked or not!

Try using

document.getElementsByName('XXX')[0].checked

To check the status of whether it's checked or not.