Rodrigo Zurek
Rodrigo Zurek

Reputation: 4575

angular js jsonp example dosn't works

im having trouble using the angular js jsonp function, i cant make this plunk to work:

http://plunker.co/edit/xQVBchTYOro1CB979021

can anyone help me?

Upvotes: 1

Views: 838

Answers (2)

pkozlowski.opensource
pkozlowski.opensource

Reputation: 117370

With the JSONP "hack" you must make sure that the server's response contains callback's invocation. To make your example work you should change the prov.json file so it looks like follows:

angular.callbacks._0({
   "id": "40796308305",
   "about": "The Coca-Cola Facebook Page is a collection of your stories showing how people from around the world have helped make Coke into what it is today.",
   ...
})

There are many sources on JSONP, ex.: What is JSONP all about?

Upvotes: 1

salek
salek

Reputation: 444

using a get instead of jsonp, you get the details of cokacola...

 async: function(page) {
  var url = 'prov.json';     
    var promise = $http.get(url).error(function (response, status) {
      alert("fai");
    }).success(function (response, status) {
      alert(response.about);
    }).then(function (response, status) {
      return response.data;           
  });
  return promise;
}};

Upvotes: 0

Related Questions