How to use JSON.stringify in datatable?
How to use JSON.stringify in datatable?
mastersuse
Posts: 61Questions: 28Answers: 0
I have read many solutions but not solve my problem.
I want to send some parameter prior to Ajax.
How to put JSON.stringify in datatable?
I got this ajax error
1st try
$('#userTable').DataTable({
processing: true,
ajax: {
url: api_url,
crossDomain : true,
type : "POST",
cache : false,
dataType : "json",
contentType: "application/json",
dataSrc : "",
data: {
"uid": $("#session_userid").text(), // this is read user session
"tokenid": $("#session_tokenid").text(), // this is read user token session
"item": "user",
"action": "read",
"type": "1",
"keyword": ""
}
},
columns: [
{ data : "full_name" },
{ data : "userid" },
{ data : "level" },
],
});
2nd try
$('#userTable').DataTable({
processing: true,
ajax: {
url: api_url,
crossDomain : true,
type : "POST",
cache : false,
dataType : "json",
contentType: "application/json",
dataSrc : "",
data: {
return JSON.stringify({"uid": $("#session_userid").text(), "tokenid": $("#session_tokenid").text(), "item": "user", "action": "read", "type": "1", "keyword": "" });
}
},
columns: [
{ data : "full_name" },
{ data : "userid" },
{ data : "level" },
],
});
This discussion has been closed.
Answers
Is this the same issue as your other thread?
Colin
yes
Please only post a thread once...
ok sorry, but please assist me.