Skip to content

Instantly share code, notes, and snippets.

@tcdevs
Created June 19, 2013 11:01
Show Gist options
  • Save tcdevs/5813487 to your computer and use it in GitHub Desktop.
Save tcdevs/5813487 to your computer and use it in GitHub Desktop.
Howto load SJONP with angular's $http
app.controller('myController', function ($scope, $http ) {
$scope.fetch = function () {
$scope.url ="http://my-json-url.com";
$scope.status = null;
$scope.data = data;
var query = $scope.url + "&callback=JSON_CALLBACK";
$http({method: "JSONP", url: query}).
success(function(data, status) {
$scope.status = status;
$scope.data = data;
}).
error(function(data, status) {
$scope.status = status;
$scope.data = data || "Request failed";
});
}; //End fetch
}); // End myController
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment