首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在MVC c#中,未从对控制器的ajax调用中获取数据作为数组数据

在MVC c#中,未从对控制器的ajax调用中获取数据作为数组数据
EN

Stack Overflow用户
提问于 2019-06-09 19:29:18
回答 2查看 37关注 0票数 0

cshtml页面中的## AJAX调用

代码语言:javascript
复制
function ValidateData() {
            var editedRows = [];
            $("#eventsTable tbody tr").each(function () {
                editedRows.push({
                    PK_WS_Event: $(this).find("td:eq(1)")[0].innerText,
                    Act_Id: $(this).find("td:eq(2)")[0].innerText,
                    WeeklyStatus: $(this).find("td:eq(3) option:selected").text()
               == "--Select--" ? "" : $(this).find("td:eq(3) 
          option:selected").text(),
                    WeeklyStatusSubType: $(this).find("td:eq(4)  
         option:selected").text() == "--Select--" ? "" : $(this).
         find("td:eq(4) option:selected").text(),
                    AccountName: $(this).find("td:eq(5)")[0].innerText,
                    AccountNumber: $(this).find("td:eq(6)")[0].innerText,
                    WeeklyStatusDesc: $(this).find("td:eq(7)")
             [0].textContent.trim(),
                });
            });

            $.ajax({
                type: 'post',
                url: "/WeeklyStatus/IndexSubmit",
                data: JSON.stringify({ editedRows: editedRows }),
                contentType: 'application/json',
                dataType: "html",
                success: function (response) { 
                },
                error: function (xhr, status, error) {
                    alert('fail');
                }
            });
        }



    ## Server Code Controller and ##
    ----------
       [HttpPost]
            public IActionResult IndexSubmit(IList<WeeklyStatusEvents> 
          editedRows)
            {
                return null;
            }

我的ViewModel如下..

代码语言:javascript
复制
public class ReportViewModel
{
    public int SelectedStatusId { get; set; }
    public int SelectedSubTypeId { get; set; }


    public List<WeeklyStatusEvents> statusEvents { get; set; }

}

和WeeklyStatusEvents模型,如下所示

代码语言:javascript
复制
public class WeeklyStatusEvents
{

    public string PK_WS_Event { get; set; }
    public string Act_Id { get; set; }
    //public bool INDExcludeFromRpt { get; set; }
    public string WeeklyStatus { get; set; }
    public string WeeklyStatusSubType { get; set; }
    public string AccountName { get; set; }
    public string AccountNumber { get; set; }
    public string WeeklyStatusDesc { get; set; }


}

所以在这里,我的计数是0.

我已经创建了具有所有这些属性的类。我在ajax调用中也使用了相同的属性名。

就连我也没有得到数据。你能提供我在获取数据时错过的解决方案吗?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56514211

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档