c# - MVC5 Ajax.BeginForm refresh whole page -
why form post not happening via ajax instead reloading new page?
my .js includes:
<script src="/app/javascript/libraries/jquery-1.11.1-min.js"></script> <script src="/app/javascript/libraries/jquery.validate.js"></script> <script src="/app/javascript/libraries/jquery.validate.unobtrusive.js"></script>
my razor view:
<div id="login-partial-update"> @using (ajax.beginform("login",null, new ajaxoptions { updatetargetid = "login-partial-update", httpmethod = "post" }, new { id = "js-form-login" })) { @html.textboxfor(x => x.email, new {placeholder = "email address"}) <div class="errormessage"> @html.validationmessagefor(x=>x.email) </div> @html.passwordfor(x => x.password, new {placeholder = "password"}) <div class="errormessage"> @html.validationmessagefor(x => x.password) </div> } </div>
my controller code:
[httppost] public actionresult login(logininputmodel login) { return partialview("widgets/popups/_logininput", login); }
am forgetting something?
you have include jquery.unobtrusive-ajax.js
file in view make ajax.beginform
work.
Comments
Post a Comment