I wrote a little web service using Slim Framework 3 (in PHP), all returned data are made with this instruction :
return $response->withJson($liste);
Then I wrote a HTML client using "jquery.rest" plugin, I can see JSON results but can't understand the structure and how to read all these data, please have a look on browser's console :

I want to write a loop to display the data, but can't figure it out !

Thanks :)
You are getting an array of objects in a response as per the browser console.
You can parse this response in different ways :
using for in loop :
var obj = [
{"id":"1","task":"Find Bugs","status":"1","created_at":"2016-04-10 23:50:40"},
{"id":"2","task":"Review","status":"1","created_at":"2016-04-10 23:50:40"}
];
for (var i in obj) {
console.log("Task is :"+obj[i].task);
}
using array map() method :
var obj = [
{"id":"1","task":"Find Bugs","status":"1","created_at":"2016-04-10 23:50:40"},
{"id":"2","task":"Review","status":"1","created_at":"2016-04-10 23:50:40"}
];
var res = obj.map(function(item) {
return item.task;
});
console.log(res);
using ng-repeat :
var myApp = angular.module('myApp',[]);
myApp.controller('MyCtrl',function($scope) {
$scope.obj = [
{"id":"1","task":"Find Bugs","status":"1","created_at":"2016-04-10 23:50:40"},
{"id":"2","task":"Review","status":"1","created_at":"2016-04-10 23:50:40"}
];
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl">
<div ng-repeat="item in obj">
{{item.task}}
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With