How to pass an Ajax URL with params inside a ajax.url() method?
How to pass an Ajax URL with params inside a ajax.url() method?
aranhaqg
Posts: 3Questions: 1Answers: 0
Hi guys,
I'm trying to change the url of an existing table and load it. How can I pass params in this ajax.url method?
I wanna do somethig like this:
var oTable;
$(function(){
oTable = $('.sortable').DataTable({
bRetrieve: true,
bProcessing: true,
bServerSide: true,
ajax: 'my_url.php',
sPaginationType: 'full_numbers',
});
$("#my_checkbox").change(function(){
//Wanna use my new url and params here
contratosTable.ajax.url(new_url, params).load();
});
});
Thanks for attention!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
ajax.data
I'm sorry, DirceuNazareth.
But where is contratosTable.ajax.url(new_url, params).load() is supposed to be oTable.ajax.url(new_url, params).load().
I wanna pass the params at the new URL at the same table (oTable) that was deffined before.
Could you tell me how to pass params in the .ajax.url method?
CORRECT CODE:
I am noticing by your code that you may are using the version 1.9 or below... I am not so familiar with that. I change for 1.10 more than year, so I will give the explanation based on 1.10, because they are very well mirrored and you can find the correlations. If that not worth for you, feel free to ignore the comment.
The DataTable API has a method to get the parameters of some table:
If you want to pass the parameter to be get as
$_GET
in the PHP page you just need to added to your url:If you want to pass the parameter to be posted and recovery it on PHP using
$_POST
, it should not change the parameters anyway... but, if you want control the parameters, then you need change your initialization to instead of useajax: url
, useajax: object
,like:
Thanks!!