Checkbox sends 'on when serialized

Asked

Viewed 15 times

-1

I have an html form that sends the data via ajax like this:

function showValues() {
  $.ajax({
    type: "get",
    url: "/Home/salvaItem",
    data: $("form").serialize(),
    success: function (data) {
      $("#results").text(data);
    }
  });

  return false;
}

Everything is fine, however, I have 3 fields that are checkbox where I am waiting the value 1 or 0 to treat, and the same is being sent 'on' or not send.

I’ve tried it this way <input type="checkbox" name="delivery" checked="1"> Entrega a domicílio to see if it forces the same to send the number 1, but without success.

Some help?

1 answer

0


I solved using:

<input type="checkbox" name="delivery" value="1">

Browser other questions tagged

You are not signed in. Login or sign up in order to post.