admin管理员组文章数量:1421752
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.
本文标签: javascriptCheckbox ajax request on checkuncheckStack Overflow
版权声明:本文标题:javascript - Checkbox ajax request on checkuncheck - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745314601a2653091.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论