Posting form to different MVC post action depending on the clicked submit button

后端 未结 4 998
南方客
南方客 2020-12-07 16:23

I am using ASP.Net MVC 4. I have multiple buttons on a view.. At present I am calling the same action method; and I am distinguishing the clicked button using a

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 16:59

    you can use ajax calls to call different methods without a postback

    $.ajax({
        type: "POST",
         url: "@(Url.Action("Action", "Controller"))",
         data: {id: 'id', id1: 'id1' },
         contentType: "application/json; charset=utf-8",
         cache: false,
         async: true,
         success: function (result) {
            //do something
         }
    });
    

提交回复
热议问题