1

No error but no data. Is there an option I need to add to make this work? my data uses the result from an ajax call.

Any suggestions?

Code:

    $.ajax({
        cache: false,
        url: "http://a.co.nz/GetTestDocs",
        data: '{'
          + '   "oldCompanyIdString": "' + selectOldCompanyId + '", '            
         + '    "effectiveDateString": "' + selectEffectiveDate + '", '
         + '    "endDateString": "' + selectEndDate + '",'
         + '   "userToken": "' + userToken + '"'
         + ' }',
        type: "POST",
        //jsonpCallback: "Value",
        contentType: "application/json",
        dataType: "json",
        error: function (jqXHR, textStatus, errprThrown) {
            //console.log(errprThrown);
            //window.location = location;
        },
        success: function (value) {
            if (value.GetTestDocsResult != null) {
                result = $.parseJSON(value.GetTestDocsResult);
                if (result.length == 0) {
                    alert("Your query did not return any data.");
                }
                else {
                    console.log(result);
                    bindDataTable(result.DocsList);                   
                }
            }
        }
    });

    function bindDataTable(data) {
    $('#docuList').dataTable({
        "processing": true,
        "ajax": data,
        "columns": [
            { "data": "Description" },
            { "data": "FileLocation" }]

    });
}

Help pls..my first time to use dataTables

4
  • Does your ajax call actually return any data? Commented Dec 3, 2014 at 9:47
  • No, it returns DocsList but I did replace it with that, still didn't work though Commented Dec 4, 2014 at 1:18
  • do you get any js errors? Commented Dec 4, 2014 at 9:33
  • No, there are no errors Commented Dec 11, 2014 at 21:42

1 Answer 1

1

Replace "ajax": data, with "data": data,

function bindDataTable(data) {
    $('#docuList').dataTable({
        "processing": true,
        "data": data,
        "columns": [
            { "data": "Description" },
            { "data": "FileLocation" }
        ]
    });
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.