When I do an ajax call to a spring server, I got this
{
"colors" : [ {
"id" : 2,
"name" : "A1 Classic"
} ],
"dimensions" : [ {
"id" : 2,
"createdAt" : null,
"updatedAt" : null,
"name" : "1,2m"
}, {
"id" : 3,
"createdAt" : null,
"updatedAt" : null,
"name" : "100"
} ],
"products" : [ {
"id" : 6,
"createdAt" : null,
"updatedAt" : null,
"productTypes" : 1,
"name" : "test-bloc"
} ]
}
I would like to take content of colors dimensions, products and put it in their select html component.
I found this who seem interesant
https://dzone.com/articles/populate-a-jquery-dropdown-from-ajax
jQuery.ajax({
dataType: "json",
type: "get",
url: "/menu/search-reports/producttypes/" + productTypesId,
success: function (data, status, jqXHR) {
helpers.buildDropdown(
jQuery.parseJSON(data.dimensions),
$('#searchSamplesDimensions'),
'Select an option'
);
},
error: function (jqXHR, status) {
}
});
When code is running, I got
Unexpected token o in JSON at position 1