This is my table: hms_bbr_category_2
. It's just a test table, ignore the gibberish.
I need to get a console.log
working so that just in case values there will be any null data when I add new rows
Here is my Laravel controller: (my model is HmsBbrCategory
and connects to the table)
public function fetchcategory() {
$all_categories = HmsBbrCategory::all();
return response()->json([
'all_categories'->$all_categories,
]);
}
Ajax
function fetchcategory() {
$.ajax({
type: "GET",
url: "/clinical/bbr-category-configuration-data",
dataType: "json",
success: function (response){
console.log(response.all_categories);
}
});
}
My console is giving out this error when I try to show the table:
message: "Trying to get property (list of the table arrays) of non-object"
Does the error show because some of my columns have null? what can I do to output the data even with the null values?
You have error while returning response 'all_categories'->$all_categories,
public function fetchcategory(){
$all_categories = HmsBbrCategory::all();
return response()->json([
'all_categories'=>$all_categories,
]);
}