how to convert table.ajax.params()
to string format of parameters url?
I use JQuery Datatables
datatables.net
var table = $('#example').DataTable({
//... settings
});
I understand that I can get parameters with table.ajax.params()
, but I want to send them for server with correct format:
draw: 1
columns[0][data]: id
columns[0][name]:
columns[0][searchable]: true
columns[0][orderable]: true
columns[0][search][value]:
columns[0][search][regex]: false
columns[1][data]: version
columns[1][name]:
columns[1][searchable]: true
...
but my URL is looks like above:
http://localhost:80/api/v1/users?[object%20Object]
correct format is:
http://localhost:80/api/v1/users?draw=1&columns%5B0%5D%5Bdata%5D=id&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=true&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&...
Thank you for your time
I can do it. I use $.param(parameters)
and set as data in ajax
JQuery
my code is:
let parameters = table.ajax.params();
let queryString = $.param(parameters);
$.ajax({
type: "GET",
url: 'http://localhost:80/api/v1/users',
data: queryString,
contentType: "application/json",
encode: true,
}).done(function (data) {
// ....
}).fail(function (err) {
// ....
});