Posting same form to different actions depending on button clicked

前端 未结 2 1028
逝去的感伤
逝去的感伤 2021-01-18 11:36

I have a similar post on this on StackOverflow but perhaps my misunderstanding is more substantial. I have an action Index() and an Index view its rendering. From Index()

2条回答
  •  抹茶落季
    2021-01-18 12:08

    Additional to accepted answer when you are in need to change action as well as Controller too:

    $('#go_button').click(function() {
        $('form').attr("action", "@("Search","OtherControllerName")");  //change the form action
        $('form').submit();  // submit the form
    });
    

提交回复
热议问题