invalid json response

invalid json response

AbuMaizarAbuMaizar Posts: 14Questions: 6Answers: 1

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

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    Answer ✓

    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.

  • AbuMaizarAbuMaizar Posts: 14Questions: 6Answers: 1
    edited April 2017

    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%"
    }
    ]
    })
    });

    File Number Patient Name DOB
    File Number Patient Name DOB
    <WebMethod()> _
    

    <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

  • AbuMaizarAbuMaizar Posts: 14Questions: 6Answers: 1
    Answer ✓
This discussion has been closed.