使用laravel时angularjs$http:Server500(内部服务器错误)
我已经找到了很多解决方案,但仍然无法奏效。 它告诉我使用laravel时angularjs$http:Server500(内部服务器错误),angularjs,laravel-4,filter,ionic-framework,Angularjs,Laravel 4,Filter,Ionic Framework,我已经找到了很多解决方案,但仍然无法奏效。 它告诉我 POST http://localhost/travelAbroad/public/touristsData 500 (Internal Server Error) 我想做的是,当我选择过滤器时,将根据您选择的过滤器进行更改。我使用ionic作为前端框架来制作html5移动应用程序 以下是我的代码: //html <span class="ion-ios-arrow-down button button-icon" ng-cl
POST http://localhost/travelAbroad/public/touristsData 500 (Internal Server Error)
我想做的是,当我选择过滤器时,将根据您选择的过滤器进行更改。我使用ionic作为前端框架来制作html5移动应用程序
以下是我的代码:
//html
<span class="ion-ios-arrow-down button button-icon" ng-click="modal.show()"></span>
...
<ion-list>
<ion-item ng-repeat="tourist in tourists | limitTo:numberOfItemsToDisplay">
<h3>Charge: $@{{tourist.charge}}/h</h3>
</ion-item>
</ion-list>
//后端
//拉维尔路线:
Route::match(array('GET', 'POST'), '/touristsData', array(
'uses' => 'UserController@touristsData',
'as' => 'touristsData'
));
//拉威尔控制器:
public function touristsData(){//get
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
//$postdata = json_decode(file_get_contents('php://input'));
if(isset($request->location)){
@$location = $request->location;
$tourists = User::where('block','0')
->where('location', $location)
->orderBy('updated_at', 'desc')
->get();
}else{
$tourists = User::where('block','0')
->orderBy('updated_at', 'desc')
->get();
}
//$touristsPostInfo = Post::where('block','0')->get();
return View::make('frontend.data.touristsData',array('tourists'=>$tourists));
}
//旅游者数据
echo json_encode($tourists);
在标题中包含以下内容:
<meta id="token" name="token" content="{{ csrf_token() }}">
这种错误被捕获到服务器的错误日志文件中, 您可以使用FTP登录并获取error.log文件,以准确地检查行和问题所在
$http: server 500 (Internal Server Error)
您的服务器需要一个url编码的字符串,并且您通过一个对象发送,因此它会抛出错误 更新如下
data: {
location: $scope.filter.location
}
到
您需要插入
$httpParamSerializer
函数。我将其放入并将“var token=$scope.filter.token;”更改为“var token=document.getElementById('#token').getAttribute('content');”在我的submitForm函数中。但还是不起作用。我遗漏了什么吗?谢谢,我使用了本地环境和laravel框架。laravel.log中的错误没有显示非常详细的信息。Apache服务器(如果您使用Apache)每次在PHP文件上崩溃时都会创建并更新error.log,因此它独立于本地和框架,我一直使用它来处理PHP错误。不管怎样,没问题,祝你好运。可能是
$http: server 500 (Internal Server Error)
data: {
location: $scope.filter.location
}
data : $httpParamSerializer({
location: $scope.filter.location
})