保存表单数据而不使用$(&#“Form"”)提交表单.serializeArray() [英] Save form data without Submitting form using $("#Form").serializeArray()

查看:258
本文介绍了保存表单数据而不使用$(&#“Form"”)提交表单.serializeArray()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用$(#Form)以保存表单数据而不提交表单的任何方式。 serializeArray()。当我使用serializeArray时,它仅适用于表单提交和n 使用单击按钮



当我打电话时这个函数来自cshtml页面,我没有在我的控制器(Model)中获取表单数据。我的代码是,



 功能 SaveCall() {
$( #ItemData)。val( JSON .stringify($( #jqxOpStockGrid)。jqxGrid(< span class =code-string>' getboundrows')));

$ .ajax({
url:' / INVOpeningStock / create'
类型:' POST'
data:$( #INVOpeningStock_Form)。serializeArray(),
cache: false
aync: false
成功: function (数据){
if (!data.success){

} 其他 {



}
}
});
}







在我的控制器方法中调用Ajax。但参数模型是空的。我的控制器方法是:





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





我的cshtml页面代码是



 @ using(Html.BeginForm(new {id =INVOpeningStock_Form}) )
{
@ Html.AntiForgeryToken()
@ Html.ValidationSummary(true)
< fieldset class = fieldset >
< width = 100% align = center < span class =code-attribute> 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 >

解决方案

(#Form)。 serializeArray()。当我使用serializeArray时,它仅适用于表单提交和n 使用单击按钮



当我打电话时这个函数来自cshtml页面,我没有在我的控制器(Model)中获取表单数据。我的代码是,



 功能 SaveCall() {


#ItemData)。val(< span class =code-sdkkeyword> JSON .stringify(


#jqxOpStockGrid)。jqxGrid(' getboundrows')));

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>

解决方案

("#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')));


这篇关于保存表单数据而不使用$(&#“Form&quot;”)提交表单.serializeArray()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆