【问题标题】:How to insert List data from ajax如何从ajax插入列表数据
【发布时间】:2023-04-03 08:57:01
【问题描述】:

我有两个实体

关系是 1:N。

一个实体有List<Bentity> getList = new ArrayList<>();

我会从 jsp ajax 数据中发送一些数据。

var data={
  a:1,
  b:2,
  getList[0].abcdKey:1
}

$.post(url,data,function(){ blah})

一个大小的数组已发送,但 2 个或更多大小的数组无法发送。

我试试

var getList=[]
    var data=[1,2,3,4]  // it is  "getList[0].abcdKey:1'"s data
        data.forEach(function(){ 
        getList.push({

           getList[i].abcdKey:1  //then occured error
        })
        })

var data={
      a:1,
      b:2,
      getList
    }

    $.post(url,data,function(){ blah})

我对我的代码进行了哪些更改?

后端 Spring-boot 前端jsp+jquery+javascript

【问题讨论】:

  • 这是什么语言?
  • 后端spring boot前端jsp谢谢
  • getList 里面有什么?发布它并检查您的控制台是否有错误
  • 是的斯瓦蒂。里面的getList

标签: arrays ajax spring-boot jsp arraylist


【解决方案1】:

这个解决方案怎么样:

var data={       }
data[getKey(i)]= somevalue;


 var getKey = function(i) {
        return 'getList['+i+'].abcdKey';
    };

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-16
    • 2020-01-14
    • 1970-01-01
    相关资源
    最近更新 更多