asp.net mvc - MVC: Set action name using javascript fails -
i need set action form posts using javascript. tried this:
$('form').get(0).setattribute('action', formaction); and
$("#form").attr('action', formaction); in both cases, query malformed, this:localhost:xxxx//controller/action1/action2 why happen? how can correctly set action form posts ? complete javascript function this
function getnotiftype() { formaction = "editwithdifferenttype"; $("#form").attr('action', formaction); $("#form").submit(); }
i used @url.action() qualified url action, , worked:
formaction = '@url.action("editwithdifferenttype", "notifications")'; $("#form").attr('action', formaction); $("#form").submit();
Comments
Post a Comment