Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getStuff(num, onContents){
- $.getJSON('http://whateverorigin.org/get?url=' + encodeURIComponent('http://catholic.com/api-radio/' + num) + '&callback=?', function(data){
- //call the oncontents callback instead of returning
- onContents(data.contents);
- });
- }
- //when calling getstuff, pass a function that tells what to do with the contents
- getStuff(6387, function(contents){
- window.GlobalVar = contents;
- });
- var NewVar = window.GlobalVar;
- alert(NewVar);
- getStuff(6387, function(contents){
- // the following statement will assign the value of 'contents' to the global variable 'GlobalVar'
- window.GlobalVar = contents;
- });
- var NewVar = window.GlobalVar;
- alert(NewVar);
- function getStuff(num) {
- $http.jsonp('http://whateverorigin.org/get?url=' + encodeURIComponent('http://catholic.com/api-radio/' + num) + '&callback=JSON_CALLBACK')
- .success(function (contents) {
- $scope.shows = contents;
- });
- };
- getStuff(6387);
- .success(function (response) {
- var result = angular.fromJson(response.contents);
- $scope.shows = result.shows;
- });
- <ul>
- <li ng-repeat="show in shows">{{ show.title }}</li>
- </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement