Created
June 19, 2013 11:01
-
-
Save tcdevs/5813487 to your computer and use it in GitHub Desktop.
Howto load SJONP with angular's $http
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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