invalid json response
invalid json response
Hi allan
I m posting my server side output
[["15112777","marwam saleh moh saleem"],null],
I keep getting invalid JSON response
My web browser gives me this error
jquery.dataTables.js:3929 Uncaught TypeError: Cannot set property 'data' of null
at _fnBuildAjax (jquery.dataTables.js:3929)
at _fnAjaxUpdate (jquery.dataTables.js:3946)
at _fnDraw (jquery.dataTables.js:3409)
at _fnReDraw (jquery.dataTables.js:3528)
at _fnInitialise (jquery.dataTables.js:4710)
at loadedInit (jquery.dataTables.js:1320)
at HTMLTableElement.<anonymous> (jquery.dataTables.js:1332)
at Function.each (jquery-2.1.4.js:374)
at jQuery.fn.init.each (jquery-2.1.4.js:139)
at jQuery.fn.init.DataTable [as dataTable] (jquery.dataTables.js:869)
any idea why?
Thanks
This question has accepted answers - jump to:
Answers
Need to see your datatable definition but my guess is that you are not return data or your table is expecting an array of object but you are sending it an array of arrays.
Thank you ,
I m posting the whole method as below,
$(document).ready(function () {
var $table = $('#RegSrc2');
$table.dataTable({
bProcessing: true,
"serverSide": true,
"sAjaxSource": $table.data('../CONFIG/WebSerTblsSearch.asmx/SrcTblRegx'),
"columns": [
{
"data": "Filenum",
"width": "10%"
},
{
"data": "FullName",
"width": "10%"
}
]
})
});
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Function SrcTblRegx()
Dim constr As String = ConfigurationManager.ConnectionStrings("ARTSQLConStrng").ConnectionString
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand("TblRegSearchx", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = con
Dim ds As New DataSet()
Using sda As New SqlDataAdapter(cmd)
sda.Fill(ds)
End Using
Dim MArray()() As String = New String(ds.Tables(0).Rows.Count)() {}
Dim i As Integer = 0
For Each rs As DataRow In ds.Tables(0).Rows
MArray(i) = New String() {rs("Filenum").ToString(), rs("FullName").ToString()}
i = i + 1
Next
Dim js As JavaScriptSerializer = New JavaScriptSerializer()
Dim sJSON As String = js.Serialize(MArray)
Return sJSON
'Dim jsondata As String = JsonConvert.SerializeObject(ds)
'Return jsondata
End Using
End Using
End Function
Bindrid answer is here,
http://stackoverflow.com/questions/43645019/datatable-jquery-plugin-implementation?noredirect=1#43648097
thanks a lot Bindrid