c# - Data Table Ajax Call -
i trying fetch data database through jquery datatable , gives error as:
"datatables warning: table id=tblbinddata - cannot reinitialise datatable."
function binddata() { $("#tblbinddata").datatable({ "processing": true, "serverside": true, "sajaxsource": "firsttask.aspx/populatedatatable", "fnserverdata": function (ssource, aodata, fncallback) { aodata.push({}); $.ajax({ "datatype": 'json', "contenttype": "application/json; charset=utf-8", "type": "post", "url": ssource, "data": aodata, "success": function (msg) { var json = jquery.parsejson(msg.d); fncallback(json); $("#tblbinddata").show(); }, error: function (xhr, textstatus, error) { if (typeof console == "object") { console.log(xhr.status + "," + xhr.responsetext + "," + textstatus + "," + error); } } }); } }); }
there mistakes in code,
- you have given
datatype:json, there no need usingjquery.parsejson(msg.d). - if using
"contenttype": "application/json; charset=utf-8",, should serialize data before passing ajax. better removecontenttypeyur ajax call.
Comments
Post a Comment