I'm just getting started on AngularJS and for some reason I'm having a problem. I'm running an http get query to the Last.fm API in order to retrieve similar artists to Caravan. I have tried the query on a web browser and it returns the correct XML response.
This is my controller:
function ArtistsCtrl($scope, $http) {
//artist: $scope.artist;
$scope.getArtists = function() {
$http.get('http://ws.audioscrobbler.com/2.0/?method=artist.getsimilar&artist=Caravan&api_key=MY_API_KEY').success(function(data) {
echo(data);
}).error(function(data, status, headers, config){
echo(data);
});
};
};
And this is my view:
<!doctype html>
<html lang="en" ng-app>
<head>
<meta charset="utf-8">
<title>My HTML File</title>
<link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="css/bootstrap.css">
</head>
<body>
<div ng-controller="ArtistsCtrl">
<button ng-click="getArtists()">Get artists</button>
</div>
<script src="angular.js"></script>
<script src="angular-resources.js"></script>
<script src="app.js"></script>
</body>
</html>
The problem is that when I click on the button and it executes $http.get, it throws the following exception and never returns any data.
[Exception... "" nsresult: "0x805e0006 (<unknown>)" location: "JS frame :: http://localhost/AngularJS/angular.js :: createHttpBackend/< :: line 9409" data: no]
http://localhost/AngularJS/angular.js
Line 5764
Anyone has any idea about what could be the problem? Thanks.
Tried downloading AngularJS 1.0.5 and it worked fine, it gives me the error on 1.1.3 .