$http.jsonp doesn't load in data?

2019-09-09 22:57发布

问题:

So i've got this piece of code that works and loads in fine:

function fetchSpecific() {
              $http.get("http://www.omdbapi.com/?t=" + $scope.search + "&tomatoes=true&plot=full")
                .success(function(response) {
                  $scope.details = response;
                  console.log(response);
                });

              $http.get("http://www.omdbapi.com/?s=" + $scope.search)
                .success(function(response) {
                  $scope.related = response;
                });
            };

The $scope.details gets filled in and i get output in my webapp.

If i try this:

function fetch() {
              $http.jsonp("http://www.myapifilms.com/imdb/top")
                .success(function(response) {
                  $scope.details = response;

                  console.log(response);
                  console.log(details);
                });
            };

I don't see any console.log outputs, if i try this in my .html file :

        <div>
        {{details}}
        </div>

i don't see any output. I'm using the correct controller, but it seems details isn't getting filled in. I thought "huh maybe the url to which i request is bad", but when posting http://www.myapifilms.com/imdb/top in my browser, i get a json object back. So if i get that back, details should get filled and i should be able to display it in json format, right? What am i doing wrong?