How to post ASP.NET MVC Ajax form using JavaScript rather than submit button

后端 未结 8 643
小鲜肉
小鲜肉 2020-11-30 23:20

I have a simple form created using Ajax.BeginForm:

<% using (Ajax.BeginForm(\"Update\", \"Description\", new { id = Model.Id         


        
8条回答
  •  孤街浪徒
    2020-12-01 00:00

    Ajax.BeginForm looks to be a fail.

    Using a regular Html.Begin for, this does the trick just nicely:

    $('#detailsform').submit(function(e) {
        e.preventDefault();
        $.post($(this).attr("action"), $(this).serialize(), function(r) {
            $("#edit").html(r);
        });
    }); 
    

提交回复
热议问题