So I have only recently began using ajax with jQuery. I am wondering if it is possible to limit or specify what you want back from the response.
So say I had the following, and I only wanted to get the first 3 people or the last 3 out of a 100 people.
$.ajax({
type: "GET",
url: "/people"
dataType: "json",
success: function(data) {
// Do some awesome stuff.
}
});
Now, I know you can pas and optional data object. Could this data object be used to limit or specify the response I want?
Thanks for any help!
You should do the filter in the server side. Pass the parameter use data
.
$.ajax({
type: "GET",
url: "/people",
data: {limit: 3, order: 'desc'},
dataType: "json",
success: function(data) {
// Do some awesome stuff.
}
});
Then in the server side, return the response based on limit
and order
.
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