In my controller, i add multiple parameters to model attribute by some ids. for example added elements to my model in controller can be such as:
_104group
_105group
_106group
.
.
.
And so on
this elements added dynamically in controller and depends on database values. Each of these elements has a list of MainCommodity
object. Now how can i get content of these elements in $.getjson
?
java script is as follows:
$(document).ready(function() {
$.getJSON("<c:out value="${pageContext.request.contextPath}" />/mainCommodity/mainCommodity/load.html", function(object, result) {
if (object.is_error == "1") {
$("#addTranceButton").hide();
var statusMessageKey = object.statusMessageKey;
if (statusMessageKey.trim() != "") {
$("#messages").show();
$("#messageLabel").show() ;
$("#messageLabel").html(statusMessageKey);
}
}
else {
for(i=0;i<commGroups.length;i++){
alert(object);
}
}
});
I other words, i need into for loop of $.getjson success function:
object._104group
and object._105group
and object._106group
and so on .
Finally i solved my problem as follows:
for(i=0;i<commGroups.length;i++){
var obj = Object.values(object);
alert(obj[i]);
}