{"id":1347,"date":"2022-08-30T15:15:46","date_gmt":"2022-08-30T15:15:46","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/13\/checkbox-not-working-with-ajax-and-jquery-1-10-2-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:15:46","modified_gmt":"2022-08-30T15:15:46","slug":"checkbox-not-working-with-ajax-and-jquery-1-10-2-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/checkbox-not-working-with-ajax-and-jquery-1-10-2-collection-of-common-programming-errors\/","title":{"rendered":"checkbox not working with ajax and jquery 1.10.2-Collection of common programming errors"},"content":{"rendered":"<p>UPDATE: Looks like the &#8220;data-val=&#8217;true&#8217; attribute of the rendered input field causes the error. the Html.CheckBoxFor() generates this html<\/p>\n<pre><code>\n                \n<\/code><\/pre>\n<p>If i use that exact code in my View but delete the &#8220;data-val=&#8217;true'&#8221; attribute, it works correctly.<\/p>\n<p>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.<\/p>\n<p>Uncaught SyntaxError: Unexpected token u jquery-1.10.2.js:550<\/p>\n<p>Any ideas?<\/p>\n<p>Thanks<\/p>\n<p>Below is the block of code that I use<\/p>\n<pre><code>@using (Ajax.BeginForm(\"Login\", \"Account\", FormMethod.Post, new AjaxOptions { UpdateTargetId = \"loginForm\" }))\n{\n    @Html.AntiForgeryToken()\n    \n        \n        <\/code><\/pre>\n<ol>\n<li><code>@Html.LabelFor(m =&gt; m.UserName) @Html.TextBoxFor(m =&gt; m.UserName)<br \/>\n@Html.ValidationMessageFor(m =&gt; m.UserName)<\/code><\/li>\n<li><code>@Html.LabelFor(m =&gt; m.Password) @Html.PasswordFor(m =&gt; m.Password)<br \/>\n@Html.ValidationMessageFor(m =&gt; m.Password)<\/code><\/li>\n<li><code>@Html.CheckBox(\"RememberMe\", new { @checked = \"checked\" }) @Html.LabelFor(m =&gt; m.RememberMe, new { @class = \"checkbox\" })<\/code><\/li>\n<\/ol>\n<pre>\n        \n    \n    <br \/>\n        @Html.ActionLink(\"Register\", \"Register\") if you don't have an account.\n    \n    @Html.HiddenFor(m=&gt;m.RedirectUrl)\n}\n<\/pre>\n<p id=\"rop\"><small>Originally posted 2013-11-13 09:48:37. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>UPDATE: Looks like the &#8220;data-val=&#8217;true&#8217; 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 &#8220;data-val=&#8217;true&#8217;&#8221; 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. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1347","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1347"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1347\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}