asp.net mvc - Ajax.BeginForm not doing an asynchronous post -
i having problem ajax.beginform long search on internet , of solutions of including jquery.unobtrusive-ajax.min
or editing web.config
allow unobtrusivejavascriptenabled
in case both done still ajax form doing full post , can’t understand why.
in view
@using (ajax.beginform("login", "user", new ajaxoptions { httpmethod = "post", updatetargetid = "loginresult" }, new { @id = "loginform", @name = "loginform" })) { <span id="loginresultx">@(tempdata["loginresult"] != null ? tempdata["loginresult"].tostring() : "")</span> <span id="loginresult"></span> <span> @html.label("user id") @html.textbox("id")</span> <span>@html.label("password") @html.password("pwd") </span> <span> <input type="submit" value="submit" /> </span> }
in controller
public actionresult login(formcollection loginform) { if (request.httpmethod == "post") { var id= loginform["id"]; var pwd = loginform["pwd"]; bool status = false; user obj = new user(); status = obj.login(id, pwd); if (status) { session["id "] = id; return redirecttoroute("profile"); } tempdata["loginresult"] = "login failed"; } return view(); }
in bundleconfig
bundles.add(new scriptbundle("~/scr").include("~/scripts/jquery-1.7.1.min.js", "~/scripts/modernizr-2.5.3.js", "~/scripts/jquery.validate.min.js", "~/scripts/jquery.unobtrusive-ajax.min"));
are sure it's not line problem?
bundles.add(new scriptbundle("~/scr").include("~/scripts/jquery-1.7.1.min.js", "~/scripts/modernizr-2.5.3.js", "~/scripts/jquery.validate.min.js", "~/scripts/jquery.unobtrusive-ajax.min"));
you missing .js ajax file include. see it?
either way, use chrome inspector/fiddler analyse js errors or missing includes.
Comments
Post a Comment