javascript - ASP.NET MVC jQuery JSON result redirecting URL -


using mvc/json/jquery.
using form create new "group".
form on ~group/manage, posting form ~group/create whilst working on this, returning json result working fine, handling in jquery, no url redirection.
now, everytime run it, redirects me ~group/create , displays json result.

controller group/create

[httppost]     public actionresult create([bind(include="name,description")] groupmodel groupmodel)     {       ...       return json(new { success = true, message = groupmodel.name }, jsonrequestbehavior.allowget);     } 

form

 <form id="frm_creategroup" action="/groups/create" method="post">             <h2>create group</h2>             <div class="form-group">                 @html.labelfor(model => model.name, new { @for = "name" })                 @html.textboxfor(model => model.name, new { @class = "form-control", @placeholder = "group name" })                 @html.validationmessagefor(model => model.name)             </div>             <div class="form-group">                 @html.labelfor(model => model.description, new { @for = "description" })                 @html.textboxfor(model => model.description, new { @class = "form-control", @placeholder = "group description" })                 @html.validationmessagefor(model => model.description)             </div>             <span id="creategroupmessage"></span>             <button type="submit" class="btn btn-primary pull-right">create</button>          </form> 

jquery handle form

        $(document).ready(function (){         $('#navgroups').makeactivemenuitem();         var options = {              success: groupcreatesubmitted             ,error: groupcreateerror         }         $('#frm_creategroup').ajaxform(options);     });      function groupcreatesubmitted(responsetext, statustext, xhr, $form) {         if (responsetext.success)         {             $('#creategroupmessage').html = "group created";         }         else         {             $('#creategroupmessage').html = responsetext.message;         }      } 

to clear, don't want url redirection, want jquery catch return (it before, have no idea why changed...)

thanks!

removed ,error: groupcreateerror

working now...form bind failing.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -