How to call seperate ajax calls for every pagination link and search?
How to call seperate ajax calls for every pagination link and search?
san0820
Posts: 9Questions: 1Answers: 0
Hi Team,
Can any body tell me how to customize the ajax call or pass parameters into ajax url to get next or previous elements, Please Help me with this, I have been trying this since one week,
Thanks in advance
Jay,
This discussion has been closed.
Answers
If you have selected server side processing, you don't have to do anything. Just look at the request using your browsers developers tools (normally F12). If you are using a get method, the variables will be in the URL. If you are using a POST, they will be in the request body.
dataTables will send the page and the length plus other variables for filtering and ordering. It's then up to you decide how they fit into your query.
Hi Glenderson,
My URL will be like this
http://thetfn.in/TFN/dev/dbui_beta/dbui/jsondata.php/1/10
in that the last /1 --> pagenO /10 -->page size,
Where the url after pagonation is behaving like this
http://thetfn.in/TFN/dev/dbui_beta/dbui/jsondata.php/1/10?draw=4
How do customize that link
You would need to use
ajax
as a function and modify the URL to suit your request needs based on the data passed intoajax
.Allan
With the server side option selected, your URL should be
http://thetfn.in/TFN/dev/dbui_beta/dbui/jsondata.php
Upon selection of Next, Previous, Page 1, 2, 3, etc., the URL is appended by dataTables with ?draw=##& .... &start=## &length=## ... in either the URL for GET or header request body for POST.
You are most interested in the start and length.
Start is the starting record, length is the number of records selected for display. dataTable will determine the correct values to be passed.
With each pagination event (Next, Previous), dataTables fires off the ajax event with the modified URL. It's up to your ajax page to grab the request variables (start, length, etc) and create the proper SQL.