質問

I'm trying to making jsonp call using below code but doesn't seems to be working for me.

Code

var url = 'http://z:15957/Category/Categories?callback=JSON_CALLBACK';
$http.jsonp(url).success(function (data) {
    $scope.results = data.feed.entry;
});

Any help would appreciated.

役に立ちましたか?

解決

This issue appears to be with your CORS (Cross Origin Resource Sharing) issue. Your .success callback will not fire after making this call, but .error will. See the working example with the valid URL and see the .success callback executed successfully.

JSFiddle Link

var url = 'http://z:15957/Category/Categories?callback=JSON_CALLBACK';

// valid URL example
//url = 'http://public-api.wordpress.com/rest/v1/sites/wtmpeachtest.wordpress.com/posts?callback=JSON_CALLBACK'

$http.jsonp(url)               
     .success(function (data) {
         console.log(data);
    }).error(function (data, status, headers, config) {
         console.log('error');         
    });
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top