由于某种原因,我在从角线到laravel路线发布数据时遇到500间隔服务器错误。
app.js
var quora = angular.module("quora-app", ['q-controller-1', 'ngRoute', function($httpProvider) {
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
$httpProvider.defaults.headers.common['X-Requested-With'] = "XMLHttpRequest";
}]);
我的控制器
angular.module("q-controller-1",[])
.controller("q-master-1",['$scope','$location','$http',function ($scope,$location,$http) {
$scope.update=function(value,text) {
$scope.id=value;
$scope.putText=text;
}
$scope.info=[]
$scope.cancel=function() {
$location.path("/");
}
$scope.validate=function(updateInfo) {
if($scope.update.$valid) {
$scope.info.push({
id:$scope.id,
question:updateInfo.qText
});
$http({
method: 'POST',
url: 'api/update',
data: $scope.info
})
.success(function () {
console.log('true');
})
.error(function(){
console.log('false');
})
}
}
}]);
我的路由器文件
Route::group([ 'prefix' => 'api'], function() {
Route::post('/update', ['uses' => 'questionController@update']);});
记录错误
angular.min.js:103 POST http://localhost/quora/public/api/update 500 (Internal Server Error)(anonymous function) @ angular.min.js:103n @ angular.min.js:99(anonymous function) @ angular.min.js:96(anonymous function) @ angular.min.js:131$eval @ angular.min.js:145$digest @ angular.min.js:142$apply @ angular.min.js:146(anonymous function) @ angular.min.js:276dispatch @ jquery.min.js:3q.handle @ jquery.min.js:3
qaController.js:29 false
我该如何解决?