-1

Any way to Save form data without Submitting form using $("#Form").serializeArray(). When I'm using serializeArray, it works only with form submit and not working with a button click When i call this function in from cshtml page, I not getting form data in my controller (Model). My Code is,

function SaveCall() {
 $("#ItemData").val(JSON.stringify($("#jqxOpStockGrid").jqxGrid('getboundrows')));

$.ajax({
    url: '/INVOpeningStock/create',
    type: 'POST',
    data: $("#INVOpeningStock_Form").serializeArray(),
    cache: false,
    aync: false,
    success: function (data) {
        if (!data.success) {

        } else {



        }
    }
});
}

Ajax call hitting in my controller method. But the parameter model was empty. My Controller Method is:

     [HttpPost]
     public ActionResult Create(INVOpeningStock invopeningstock )
    {
     //Method Body
    }

My cshtml Page Code is

@using (Html.BeginForm(new { id = "INVOpeningStock_Form" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset class="fieldset">
<table width="100%" align="center" class="textleft">
  <tr>
     <td width="20%">
         <div class="editor-label">
              @Html.LabelFor(model => model.cName)
         </div>
     </td>
     <td width="80%" align="left">
          <div class="editor-field">
              @Html.TextBoxFor(model => model.cName, new { maxlength = 50,  @class = "textbox mediumtxt reqtext" })
          </div>
          @Html.ValidationMessageFor(model => model.cName, "", new { @class =  "required" })
      </td>
   </tr>
 </table>
</fieldset>
rgb
  • 143
  • 3
  • 15

1 Answers1

0

I'm getting data When I used

$("form").serializeArray()

Instead of

$("#INVOpeningStock_Form").serializeArray()
rgb
  • 143
  • 3
  • 15