0

I try to load a JSONP File with AngularJS. This is my code:

var urlCal = 'http://www.google.com/calendar/feeds/[email protected]/public/full';
var allParams = {
    "alt" : "json-in-script",
    "orderby" : "starttime",
    "max-results" : "15",
    "singleevents" : "true",
    "sortorder" : "ascending",
    "futureevents" : "true" 
}
$http.jsonp(urlCal + "?callback=bla", {params: allParams})
.success(function(data){
    console.log(data);
});

but when I run this in the brouwser it sows me this error: "Uncaught ReferenceError: bla is not defined "

I think the problem is that the json file starts with "// API callback" but I am not sure.

Can somebody help me?

1
  • try using callback=JSON_CALLBACK Commented Jul 21, 2014 at 15:35

1 Answer 1

2

Per Angular's $http.jsonp documentation, you need to use JSON_CALLBACK rather than a named callback:

"?callback=JSON_CALLBACK"

Angular will create the callback function name automatically. Otherwise you would have to define bla.

Sign up to request clarification or add additional context in comments.

1 Comment

The documentation is very unclear. I've to read angular source code to confirm the behavior :(

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.