你好,我有引发错误¿你可以告诉为什么一个非常基本的程序?Angularjs 500(内部服务器错误)
php的:基本上把在文件中的职位,是一个JSON。 这是一个长轮询系统的一部分。
<?php
if(empty($_POST || !isset($_POST))) {
$last_ajax = null;
} else {
$last_ajax = time();
}
clearstatcache();
$last_change = filemtime('cache.txt');
if ($last_ajax == null || $last_change > $last_ajax) {
// Load the ajax
$R = json_decode(file_get_contents('php://input'), true);
// Load into memory the file
$F = json_decode(file_get_contents('cache.txt'), true);
// If not empty the file append
if(!empty($F)) {
$S = array_merge_recursive($F, $R);
file_put_contents('cache.txt', json_encode($S), true);
// Else just write into the file the post
} else {
file_put_contents('cache.txt', json_encode($R), true);
}
echo json_encode(file_get_contents('cache.txt'), true);
break;
}
?>
而且在Angular中很简单。 这只是一个简单的POST发送到去上述数据PHP,这是一个JSON
var enrol = angular.module("enrol",[]);
enrol.controller("enrolController", function($scope, $http){
$scope.submit = function() {
console.log("Submitting");
$http({
method : "POST",
url : "dependencies/cache.php",
data : {
'action': 'enrol',
'data': {
'Login': $scope.apliclogin,
'Password': $scope.aplicpass,
'rol': {
'admin': $scope.admin,
'sala': $scope.sala,
'barra': $scope.barra,
'cocina': $scope.cocina,
'caja': $scope.caja
}
}
},
headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
}).success(function(data){
console.log(data);
});
};
});
有在parethesis一些失误,,,我固定的,仍然引发错误 – Gabriel
休息时并不需要,我可以摆脱的代码它的一半工程从一开始在quiting脱如果,只是加载和写......我满了收到的档案,但仍然得到500错误 – Gabriel
后的错误... – coatless