checkbox not working with ajax and jquery 1.10.2-Collection of common programming errors
UPDATE: Looks like the “data-val=’true’ attribute of the rendered input field causes the error. the Html.CheckBoxFor() generates this html
If i use that exact code in my View but delete the “data-val=’true'” attribute, it works correctly.
I am getting javascript error when trying to submit a form using Ajax.BeginForm() in MVC 4 and jquery 1.10.2. The problem seems to be caused by the checkbox input, because if i remove the checkbox input field it works fine. It also works fine if i use jquery 1.8.3.
Uncaught SyntaxError: Unexpected token u jquery-1.10.2.js:550
Any ideas?
Thanks
Below is the block of code that I use
@using (Ajax.BeginForm("Login", "Account", FormMethod.Post, new AjaxOptions { UpdateTargetId = "loginForm" }))
{
@Html.AntiForgeryToken()
@Html.LabelFor(m => m.UserName) @Html.TextBoxFor(m => m.UserName)
@Html.ValidationMessageFor(m => m.UserName)@Html.LabelFor(m => m.Password) @Html.PasswordFor(m => m.Password)
@Html.ValidationMessageFor(m => m.Password)@Html.CheckBox("RememberMe", new { @checked = "checked" }) @Html.LabelFor(m => m.RememberMe, new { @class = "checkbox" })
@Html.ActionLink("Register", "Register") if you don't have an account. @Html.HiddenFor(m=>m.RedirectUrl) }
Originally posted 2013-11-13 09:48:37.