문제

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