So, I have this really simple snippet in a controller where I get data from an external file using $http.get
, and it works great! But when I use $http.post
, I get a "syntaxerror: unexpected token < at object.parse(native)"
in my console.
I've included both versions below with the working $http.get
commented out.
var blogCtrl = angular.module('blogCtrl', []);
blogCtrl.controller('articleCtrl', ['$scope', '$routeParams', '$http',
function($scope, $routeParams, $http) {
//$http.get('/angular_blog/assets/php/ajaxRequests.php?action=fetchSingleArticle&permalink='+$routeParams.articlePermaLink)
$http.post('/angular_blog/assets/php/ajaxRequests.php', {action: 'fetchSingleArticle', permalink: $routeParams.articlePermaLink})
.success(function(data) {
$scope.articleTitle = data.articleTitle;
$scope.articleAuthor = data.articleAuthor;
$scope.articleContent = data.articleContent;
$scope.publishDate = data.publishDate;
$scope.category = data.category;
$scope.categoryPermaLink = data.categoryPermaLink;
});
}]);
I already tried the suggestion in this question, but it gave the same result.