I am making a ajax call using datatable but stuck on processing message
I am making a ajax call using datatable but stuck on processing message
My json returned by server, its valid json verified with jsonlint:
{"draw":1,"recordsTotal":9,"recordsFiltered":9,"data":[{"event_name":"Test Event 3","promo_code":"VTVT","promo_code_type":"fixed","promo_code_value":"2","offer_code_by":"Number","validity":"2"},{"event_name":"test event for go live","promo_code":"FFFF","promo_code_type":"percentage","promo_code_value":"1","offer_code_by":"Number","validity":"1"},{"event_name":"test event for go live","promo_code":"POPO","promo_code_type":"fixed","promo_code_value":"5","offer_code_by":"Number","validity":"5"},{"event_name":"test event for go live","promo_code":"BNBN","promo_code_type":"fixed","promo_code_value":"6","offer_code_by":"Number","validity":"6"},{"event_name":"test event for go live","promo_code":"CDER","promo_code_type":"fixed","promo_code_value":"3","offer_code_by":"Number","validity":"3"},{"event_name":"Test Event 3","promo_code":"VVVV","promo_code_type":"fixed","promo_code_value":"5","offer_code_by":"Number","validity":"5"},{"event_name":"Test Event 3","promo_code":"LATEST","promo_code_type":"fixed","promo_code_value":"4","offer_code_by":"Number","validity":"4"},{"event_name":"Date Test 2","promo_code":"1234","promo_code_type":"percentage","promo_code_value":"1","offer_code_by":"Number","validity":"2"},{"event_name":"test manoj","promo_code":"MANO25","promo_code_type":"fixed","promo_code_value":"5","offer_code_by":"Number","validity":"20"}]}
$('#offers_user').DataTable({
"bProcessing": true,
"bServerSide": true,
"columns": [
{ "data": "event_name" },
{ "data": "promo_code" },
{ "data": "promo_code_type" },
{ "data": "promo_code_value" },
{ "data": "offer_code_by" },
{ "data": "validity" }
],
"sAjaxSource": url,
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback,
"error": function (e) {
alert(e.message);
}
});
}
});
There is no PHP error from server.
Please guide, what is wrong with this code. I need the data populated in the table.
Answers
Why is your stuff not more like what is shown in the examples https://datatables.net/examples/server_side/post.html ?