New Ajax call on page change
New Ajax call on page change
Hello,
First, thank you for this awesome plugin and I need to say I'm very new to jquery.
I'm using datatables with a non rdbms (like elasticsearch) system. I'm fetching records by using an api.
To be simple: I'm trying to make a new ajax request to the api for getting the new records on page change.
Records on the data source have a unique id and I can query them by using the api like;
http://localhost/myapi?getrecords[id:1-10]&total:10
this will return the records with IDs between 1 and 10, and total of 10 records.
On every page change I need to get the current page number and display size from the user and send a call like:
http://localhost/myapi?getrecords[id:((page*size)-size)-(page*size)]&total:(size)
for example, if my display size 10(size) records and I clicked the 2nd(page) page on pagination, it will return me the records with IDs between the 10 and 20. After that I will process the records and show them to user. (btw I also can get the total number of records from the api.)
Is it possible to achieve this on page change? If yes, where should I start?
Thank you.
Answers
I would say that if you figure out a way to get the url parameters. (hint stackoverflow.com/questions/19491336/get-url-parameter-jquery-or-how-to-get-query-string-values-in-js )
Then I would recommend you look at YADCF https://github.com/vedmack/yadcf in theory I would say you can programmatically set the value of the YADCF filter on page load using the url parameters you gather.
This would do client side filtering. If you're not happy with that then I would recommend you elaborate more on
If you're using the datatables PHP server side component to do server side processing I can help out.
Hello Apezdr,
Thank you for your answer. YADCF seems nice, I'll give a try today.
I'm a bit confused with the url parameters. I thought I need to get the parameters from Datatable (page number and display size) then make a new request with the parameters I got. I think I just got you wrong..
I'm using PHP (Laravel) but not a RDBMS. Will serverside still work?
Thanks.