Adding dynamic parameters with Html.BeginForm and jQuery submit

后端 未结 1 1654
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-03 14:07
// html
<% using (Html.BeginForm(\"MyAction\", \"MyController\", 
                   new { id = ViewContext.RouteData.Values[\"id\"] },
                   FormMet         


        
1条回答
  •  -上瘾入骨i
    2021-01-03 14:35

    You could append a hidden field to the form before submitting it:

    $container.find('.myButton').click(function() {
        var form = $container.find('.myForm');
        form.append(
            $(document.createElement('input'))
                .attr('type', 'hidden')
                .attr('name', 'somename')
                .attr('type', 'somecalculatedvalue')
        );
        form.submit();
    });
    

    0 讨论(0)
提交回复
热议问题