asp.net MVC 4 submit from with ajax call

前端 未结 3 1054
长发绾君心
长发绾君心 2021-01-12 21:57

I have this in the controller:

[HttpPost]
    public ActionResult Create(Student student)
    { //somecode..

and i want to submit this from

3条回答
  •  攒了一身酷
    2021-01-12 22:31

    try this

    var form = $('#formId');
    $.ajax({
      cache: false,
      async: true,
      type: "POST",
      url: form.attr('action'),
      data: form.serialize(),
      success: function (data) {
        alert(data);
     }
    });
    

提交回复
热议问题