Reputation: 121
I have two Entity
That relations is 1:N.
A Entity has List<Bentity> getList = new ArrayList<>();
And i'll send Some data from jsp ajax data.
var data={
a:1,
b:2,
getList[0].abcdKey:1
}
$.post(url,data,function(){ blah})
One size array has done But 2 or more size Array can't sending.
I try to
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})
What i change to my code?
Back-end Spring-boot Front-end jsp + jquery+javascript
Upvotes: 0
Views: 380
Reputation: 373
how about this solution:
var data={ }
data[getKey(i)]= somevalue;
var getKey = function(i) {
return 'getList['+i+'].abcdKey';
};
Upvotes: 1