If you decide to do this on the client side:
The first argument to the success callback is the data returned from the server.
Since the type of data you expect from the server is JSON, a JavaScript object will be returned. You will get access to the first or last 3 people, as usual, in JavaScript.
For example, if the response from the server is as follows:
{ "people" : [ { name: "Foo" }, { name: "Bar" }, { name: "Baz" }, // and so on... ] }
You can access the first or last 3 people:
$.ajax({ type: "GET", url: "/people" dataType: "json", success: function(data) { // Assuming there are 100 people in the "people" array // The first three people console.log( data.people[0] ); // "Foo" console.log( data.people[1] ); // "Bar" console.log( data.people[2] ); // "Baz" } });
source share