Question

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.

Was it helpful?

Solution

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');         
    });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top