I have trouble on how to display the output of my json into success, by writing +response+
it will display [object Object]. The output will change based on id, so i think i dont need to use foreach? :/
View:-
function getItemDetails(item_id){
$.ajax({
type:'GET',
url: './itemDetails/'+item_id,
datatype: 'json',
success: function(response){
console.log(response);
$('#modalTitle').text("TITLE");
$('#variants-area-inside').append('<label class="form-control-label">'+response+'</label>');
}
});
}
Console output:-
{
"data": {
"name": "Fried Chicken Wings",
"id": 99,
"extras": [],
"options": [
{
"id": 1,
"item_id": 99,
"name": "Size",
"options": "small,medium"
}
],
"variants": [
{
"id": 1,
"price": 13,
"options": "{\"1\":\"small\"}",
"item_id": 99,
}
],
"has_variants": true,
"description": "Fried Chicken Wings"
}
}