I'm trying to perform an .ajax get to populate a table using Knockout/Jquery in Laravel 4. I use Ardent and it keeps responding with the following json response.
{"throwOnFind":false}
Controller:
public function getData()
{
$roles = Role::select(array('roles.id', 'roles.name', 'roles.id as users', 'roles.created_at'));
return Response::json($roles, 200, array('Content-Type' => 'application/json'));
}
JavaScript:
function Role(data) {
this.id = ko.observable(data.id);
this.name = ko.observable(data.name);
this.users = ko.observable(data.users);
this.created_at = ko.observable(data.created_at);
}
function ViewModel() {
var self = this;
self.roles = ko.observableArray([]);
$.ajax({
type: "GET",
url: "{{ URL::to('admin/roles/data') }}",
complete: function(allData) {
var mappedRoles = $.map(allData, function(item) {
return new Role(item);
});
}
}, "json");
self.roles(mappedRoles);
}
ko.applyBindings(new ViewModel());
I don't really know where to go from here. I think the problem may be in Ardent.