0

I am trying to run with success the example in http://jsfiddle.net/srlopez/zXPSB/4/

function MyController($scope, $http) {
$http({
    method: 'JSONP',
    url: 'https://212.142.196.44/cardiopen/episodio/list/2'
}).
success(function (data, status) {
    console.log('data:', data);
}).
error(function (data, status) {
    console.log('status:', status);
    console.log('data:', data);
});

}

It reads a JSON from that url but always get error

Uncaught SyntaxError: Unexpected token : 212.142.196.44/cardiopen/episodio/list/2 status: 0 data: undefined

And the url is ok. Can any one help me

1 Answer 1

1

Just use the shorthand method:

$http.jsonp('https://212.142.196.44/cardiopen/episodio/list/2').then(function(response){
    console.log(response.data);
});
Sign up to request clarification or add additional context in comments.

1 Comment

Adding .then(function (response) { console.log(response); return response.data; }); I have the same error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.