an angular jsonp callback
a small angular experiment requesting wordpress posts through a jsonp callback.
html
<div ng-app ng-controller="jsonp_thingy">
<button ng-click="doRequest()">Make JSONP request</button>
</div>
javascript
// pop open yr console
function jsonp_callback(data) {
// returning from async callbacks is (generally) meaningless
console.log(data.found);
}
function jsonp_thingy($scope, $http) {
$scope.doRequest = function () {
var url =
"//public-api.wordpress.com/rest/v1/sites/wtmpeachtest.wordpress.com/posts?callback=jsonp_callback";
$http.jsonp(url);
};
var url =
"//public-api.wordpress.com/rest/v1/sites/wtmpeachtest.wordpress.com/posts?callback=jsonp_callback";
$http.jsonp(url);
}
this demo preserves the compiled output and may depend on external libraries or services that are no longer available.