After testing code in this particular post and making some adjustments, I encountered an issue with obtaining a JSON object from the API of my blog created using the WordPress JSON plugin.
- URL of API from BLOG (NOT FUNCTIONING):
- URL from W3C example (WORKING): http://www.w3schools.com/website/Customers_JSON.php
I hit a roadblock while trying to manipulate the JSON API from my blog (mentioned above) even though the same code worked for the URL provided by the W3C example?
Your suggestions would be greatly appreciated.
The following codes are being utilized in the .html
file and not within a WordPress environment.
==== Angular JS Script ====
(function() {
var app = angular.module('tsApp', []);
app.controller('TSController', function($scope, $http) {
$scope.heading = [];
$http({
method: 'GET',
url: 'http://teckstack.com/api/get_recent_posts'
}).success(function(data) {
console.log("pass");
$scope.heading = data; // response data
}).error(function(data) {
console.log("failed");
});
});
})();
==== HTML ====
<html ng-app="tsApp">
<body ng-controller="TSController as tsCtrl">
<article class="main-content" role="main">
<section class="row">
<div class="content">
<div class="name-list">
<h1>Dummy Title</h1>
<ul>{{ 1+1 }} (Testing AJS is working)
<li ng-repeat="title in heading" class="">
<h3>{{title.Name}}</h3>
</li>
</ul>
</div>
</div>
</section>
</article>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html>
I have explored various solutions online before posing this question, including here and here, but unfortunately, nothing has resolved the issue for me.
For your convenience, here is a JSFiddle link: http://jsfiddle.net/236gdLnt/