I've been trying to make a search with Angular JS but I get this weird error: TypeError: undefined is not a function and it is on the .success
Here is my code:
<html ng-app="app">
<head>
<meta charset="utf-8">
<script src="angular.js"></script>
<script>
var app = angular.module('app', []);
app.controller('ctrl', function ($scope, $http){
$scope.url = 'fetch.php';
$scope.search = '';
$scope.postLink = function(){
$http.post($scope.url, { "data" : $scope.search}).succes(function(data, status){
console.log(data);
}).error(function(data, status) {
$scope.data = data || "Request failed";
$scope.status = status;
});
}
});
</script>
</head>
<body ng-controller="ctrl">
<input type="text" ng-model="search">
<input type="submit" ng-click="postLink()">
</body>
</html>
Can anyone tell my why it gives me an error on the .succes? Am I not allowed to call it there?
Thanks in advance!