【问题标题】:Return view in json value in laravel在laravel中以json值返回视图
【发布时间】:2017-05-24 14:04:58
【问题描述】:
if($listing != null) {  
    return \Response::json($listing);//return propertyees matching the search parameters
} else { 
    return \Response::json(array(["message"=>"Sorry no properties found matching your search criteria. Please try again."]),200);           
}

以 json 格式返回视图

【问题讨论】:

  • 我真的不知道您想要完成什么以及您已经尝试过什么。你能说得更具体点吗?
  • 为了给您一个很好的答案,如果您还没有看过How to Ask,它可能会对我们有所帮助。如果您可以提供minimal reproducible example,它可能也很有用。

标签: json laravel view return


【解决方案1】:
if($listing != null) { 
   return response()->json(['result' => $listing]);//return propertyees matching the search parameters
 }else {
   return response()->json((["message"=>"Sorry no properties found matching your search criteria. Please try again."]),200);
 }  

【讨论】:

    【解决方案2】:
    if($listing != null) { 
      return response()->json($listing);
     }
    

    【讨论】:

      猜你喜欢
      • 2023-03-20
      • 2020-10-11
      • 1970-01-01
      • 2015-05-06
      • 1970-01-01
      • 1970-01-01
      • 2016-05-16
      • 1970-01-01
      • 2014-08-23
      相关资源
      最近更新 更多