这是我的桌子:hms_bbr_category_2
。这只是一个测试表,忽略胡言乱语。
我需要得到一个console.log
工作,以便在我添加新行时,值会有任何空数据
这是我的 Laravel 控制器:(我的模型是HmsBbrCategory
并连接到表)
public function fetchcategory() {
$all_categories = HmsBbrCategory::all();
return response()->json([
'all_categories'->$all_categories,
]);
}
阿贾克斯
function fetchcategory() {
$.ajax({
type: "GET",
url: "/clinical/bbr-category-configuration-data",
dataType: "json",
success: function (response){
console.log(response.all_categories);
}
});
}
当我尝试显示表格时,我的控制台发出此错误:
消息:“试图获取非对象的属性(表数组列表)”
错误是否显示是因为我的某些列为空?即使使用空值,我该怎么做才能输出数据?
返回响应时出错 'all_categories'->$all_categories,
public function fetchcategory(){
$all_categories = HmsBbrCategory::all();
return response()->json([
'all_categories'=>$all_categories,
]);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句