This is my function
function getNamaKat(param1, param2) {
data = {
opt : param1,
id : param2
}
$.ajax({
type : 'POST',
url :'product_list/get_nama_kat',
dataType : 'json',
data : data,
success : function(hasil) {
return hasil.name;
},
error : function(hasil) {
alert("There is an error");
}
});
}
But I always got undefined result from the function. Here'es the reult :
description:"Kategori Pakaian" id:"574f94e0f3037ddd30ad8ac4" name:"Pakaian" status:true
And i try to get the name by this code
document.getElementById("kategori_barang").innerHTML = getNamaKat("kategori", result.categoryId);
Thankyou very much for help me.