Problem with Sending Serialized Data via Ajax Post Request - Data table
Problem with Sending Serialized Data via Ajax Post Request - Data table
hey_danish
Posts: 6Questions: 2Answers: 0
Data Is sending accurately via other Ajax Call, But while sending the data via Datatable Post request, It is getting malformed. Below is the code that I'm using.
"ajax": {
"url":r_url,
"type":r_type,
"data": r_filters,
"beforeSend": function(request) {
request.setRequestHeader("X-CSRFToken", getCookie("csrftoken") );
},
"dataSrc":'data',
},
"dom":"Bfrtip",
"bProcessing":true,
"bServerSide":true,
"bDestroy":true,
"columns":r_columns,
"aoColumnDefs": r_markups
});
Trying to send this serialize data (f_cms=2&f_cms=1&f_=FALSE&f_daterange=2019-03-08%20-%202019-03-08&filter=true) but It is sending like (f,_,c,m,s,=,2, ...)
More details are here - https://stackoverflow.com/questions/55063246/serialize-form-data-in-datatable-jquery-ajax-post
Please help to sort this out.
This discussion has been closed.
Answers
You haven't posted much information to go on. I would suggest using console.log to output debugs at various places to see how your data is handled. In the SO thread you have this function:
What does the function
initializeDatatable
do withserializeData
?Maybe you can post a link to your page or a test case so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
I solved the problem,
Line No: 22, It works after I changed
"data": r_filters
to
"data": {"extra_data":r_filters}
Wrapped in JSON Data.