I\'m a relative newbie to AngularJS, and having successfully used the GET method of $http for a basic proof-of-concept app, I\'m now trying to use the JSONP method to pull s
JSONP requires you to wrap your JSON response into a Javascript function call. When you do a JSONP the request query string will set a parameter called 'callback' that will tell your server how to wrap the JSON response.
So the response should be something like:
callback([
{"id": "1", "name": "John Doe"},
{"id": "2", "name": "Lorem ipsum"},
{"id": "3", "name": "Lorem ipsum"}
]);
Angular will define the callback parameter as angular.callbacks._0, angular.callbacks._1, angular.callbacks._2 … depending on how many requests it is waiting for response, so if you do a single request the response should be:
angular.callbacks._0([
{"id": "1", "name": "Lorem ipsum"},
{"id": "2", "name": "Lorem ipsum"},
{"id": "3", "name": "Lorem ipsum"}
]);
The server should use the callback parameter from the request string to set the response accordingly.
Check your Plunker's network activity and you will see that the request is setting the callback parameter but the response you are getting is not being wrapped with it.