Can someone help me to alert below mentioned getJSON value?
Script:
//get char values
$.getJSON(base_url + "index.php/admin/admin_controller/getjson_stock_data", function (result) {
console.log(result);
if(result.auth==="apparel"){
alert(result.val);
}
});
JSON response:
{auth: "apparel", val: Array(1)}
auth
:
"apparel"
val
:
Array(1)
0
:
{COUNT(ITEM_CAT): "3"}
length
:
1
__proto__
:
Array(0)
__proto__
:
Object
When I do the alert the results comes as [object Object].Please help me to alert the value 3.
result.valis an Entire Array.result.val[2]is the third Array element. I would avoid usingalert().alert()for debugging; it coerces types. USeconsole.log()instead