I have the following code
@foreach (var item in Model.Defaults)
{
<tr class="CertainCategory">
<td>
@item.Item1
</td>
<td>
@Html.CheckBoxFor(c => c.Use)
@Html.Hidden("guid", guid.guid.ToString())
</td>
</tr>
}
I'm trying to use AJAX to submit form values to the controller method. My problem is that the value of the checkbox is always sent as true
.
$('.CropUsageItem').each(function () {
var guid = $(this).find("#guid").val();
var chk = $(this).find("#use").val();
var data = {
guid: guid,
chk: chk
};
$.ajax({
async: false,
type: "POST",
url: "DefaultValues/SaveDefault",
data: data
});
});
I have searched StackOverflow with similar results but none of them fully apply to my scenario. How can I send the correct value?