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 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 ?
-
data: { attempt: true }
delete,
– Ron van der Heijden Commented Jul 25, 2012 at 13:06 -
um ! actually there was success function just below i deleted success function and
,
was what remained there. That was not the error though. – nebula Commented Jul 25, 2012 at 13:08
2 Answers
Reset to default 4I don't know why it didn't work but i modified slightly to make it work.
$('#Attempt').change(function () {
if ($('#Attempt').is(':checked')) {
$.ajax({
url: '@Url.Action("Select","Test")',
data: { isLocked: true },
type: 'POST',
dataType: "json"
});
}
});
You selector says find an element that has an id Attempt and than find the checkboxes inside. I believe you selector should just be the id unless I do not understand the the plating language you are using.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745314602a4622156.html
评论列表(0条)