SyntaxError: Unexpected token s at Object.parse (native) at pb (http://localhost:8080/angularjs/lib/angular.min.js:12:472) at Vc.d.defaults.transformResponse (http://localhost:8080/angularjs/lib/angular.min.js:92:314) at http://localhost:8080/angularjs/lib/angular.min.js:92:127 at Array.forEach (native) at n (http://localhost:8080/angularjs/lib/angular.min.js:6:192) at Qb (http://localhost:8080/angularjs/lib/angular.min.js:92:109) at c (http://localhost:8080/angularjs/lib/angular.min.js:93:295) at h (http://localhost:8080/angularjs/lib/angular.min.js:77:437) at http://localhost:8080/angularjs/lib/angular.min.js:78:169
这是我的代码:
index.html的:
<!doctype html> <html ng-app> <head> <script src="lib/angular.min.js"></script> <script src="js/indexApp.js"></script> </head> <body> <div> <div ng-controller="AjaxController"> {{users.data}} </div> </div> </body> </html>
indexApp.js
function AjaxController($scope,$http) { $scope.beers = [ 0,1,2,3,4,5,6 ]; console.log("OMW"); $http({ method : 'GET',url : 'data.json' }).success(function(data,status,headers,config) { $scope.users = data; }).error(function(data,config) { $scope.users = "error" + data; });
};
data.json
{ success : "true",data: [{name:"val"}] }