How to post the viewmodel to action method using JQUERY AJAX in MVC

后端 未结 3 427
伪装坚强ぢ
伪装坚强ぢ 2021-01-17 04:39

I want to achieve create (INSERT) screen using $.POST or $.AJAX.

Note: code is working fine without AJAX call..it is already there.. now i need to do ajax call and s

3条回答
  •  余生分开走
    2021-01-17 05:41

    You have forgot to add id selecter:

    $.ajax(
          {
              url: '@Url.Action("CreateProduct","ProductManagement")',
              dataType: 'json',
              contentType: 'application/json; charset=utf-8',
              type: 'post',
              data:   $('#frm').serialize(),                      // $('#frm');
              success: function () { alert('s'); },
              error: function (e1, e2, e3) { alert(e2); alert(e1 + ' ' + e2 + ' ' + e3); alert('failure event'); }
          }
        );
    

提交回复
热议问题