I have a checkbox on razor view engine as:
@Html.CheckBoxFor(model => model.Attempt, new { id = "Attempt" })
I wanted to make ajax request on each check/uncheck on the checkbox. So, i used the javascript,
$(document).ready(function () {
// Some other functions here
$('#Attempt input:checkbox').change(function () {
$.ajax({
url: '@Url.Action("Select", "Test")',
type: 'POST',
data: { attempt: true }
});
})
});
But it is not working at all. No request is being sent at all. What am i missing?
Also, how to map data attempt true or false according to check/uncheck ?
I don’t know why it didn’t work but i modified slightly to make it work.