javascript - JSON data not showing up when I change http.jsonp() URL -


i'm trying read data external json file using angularjs.

here html

<div class="panel panel-default" ng-controller="myappcontroller">     <div class="panel-heading">         <div class="input-group">             <input ng-model="query" type="text" placeholder="what file looking for?" class="form-control"><span ng-click="clearfilter()" ng-disabled="query.length == 0" class="input-group-addon"><i class="glyphicon glyphicon-remove"></i></span>         </div>     </div>     <div class="panel list-group">         <span data-ng-repeat="cat in cats | filter: query" class="list-group-item animate-repeat">{{cat.title}}     </span>         <div class="clearfix"></div>     </div> </div> 

it works fine when use in js file , data shows in list.

function myappcontroller($scope, $http) {          var url = 'http://jobs.github.com/positions.json?callback=json_callback';     $http.jsonp(url).success(function(data) {         $scope.cats = data;     }); } 

but when change url personal site nothing shows though literally copied , pasted in github json file local json file. (just test out)

function myappcontroller($scope, $http) {          var url = 'http://ciagent.com/website-files/positions.json?callback=json_callback';     $http.jsonp(url).success(function(data) {         $scope.cats = data;     }); } 

http://ciagent.com/website-files/positions.json?callback=json_callback & http://jobs.github.com/positions.json?callback=json_callback have same exact content github 1 works angular app reason.

any reasons why it's doing this?

assuming using static resource file need realize string 'json_callback' placeholder , gets modified within each $http.jsonp() request else.

you should able see in actual request url in network tab of browser dev tools.

you can open github version in browser , change value see not static on server , adjust whatever value sent.

if want use jsonp server side needs return dynamic value of callback parameter value.


Comments

Popular posts from this blog

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -