call.done - Object doesn't support property or method 'charAt'

call.done - Object doesn't support property or method 'charAt'

Jason5489Jason5489 Posts: 13Questions: 3Answers: 1

I'm new to DataTables, and I'm running into an error that I'm not sure how to get around. I've got what I believe to be a very basic DataTable, but I keep getting this error:

SCRIPT438: Object doesn't support property or method 'charAt'
File: jquery.datatables.min.js, Line: 41, Column: 249

The stack trace show that it originates at my call.done function. My syntax appears to be correct so I'm not sure how to get around this. It appears that the DataTables code is attempting to apply a charAt method to an object that is not a string. However, all the data that I'm grabbing from my document library are either "Single line of text" or "Multiple lines of text". Please see my code below and let me know if anyone sees what I'm doing wrong. Thanks!

function LoadData()
{
    var call = $.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('mylibrary')/items?$select=LinkFilename,Control%5Fx0020%5FNumber1&$filter=(Tasker1 eq '1') and (Closed1 eq '0')&orderby=Control%5Fx0020%5FNumber1 desc&$top=5000",
        type: "GET",
        dataType: "json",
        headers: {
            Accept: "application/json;odata=verbose"
        }
    });

    call.done(function (data,textStatus, jqXHR){
        $('#sacotable').dataTable({
            "bDestroy": true,
            "bProcessing": true,
            "aaData": data.d.results,
            "aoColumns": [
                { "mData": "LinkFilename"},
                { "mData": "Control_x0020_Number1"}
            ]
        });
    });

    call.fail(function (jqXHR,textStatus,errorThrown){
        alert("Error retrieving Tasks: " + jqXHR.responseText);
    });
}
       
$(document).ready(function(){
    LoadData();
});

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,864Questions: 1Answers: 10,136 Site admin

    Happy to take a look into it if you post a link to a test case showing the issue.

    Allan

  • Jason5489Jason5489 Posts: 13Questions: 3Answers: 1

    Unfortunately, I'm not able to do that. I'm working on my company's internal SharePoint site, which is under pretty strict access control. I'd be happy to answer any questions about the document library or site page you may have if that helps.

  • Jason5489Jason5489 Posts: 13Questions: 3Answers: 1

    Here's some quick facts:
    - Using SharePoint 2013
    - I'm pulling data from a document library, rather than a list
    - I'm running my code in a Content Editor on a web part page
    - I wasn't able to get the html for my table to show up in the original post, but it's just a normal table, with two table headers defined.

  • allanallan Posts: 61,864Questions: 1Answers: 10,136 Site admin

    Perhaps you could use the debugger and send me the debug code so I can take a look at it.

    I need to know what is being returned by the server.

    Allan

  • Jason5489Jason5489 Posts: 13Questions: 3Answers: 1
    Answer ✓

    This was solved by updating the version of jQuery that I was using. I was originally using 1.12.3, and I upgraded to 2.1.3.

  • allanallan Posts: 61,864Questions: 1Answers: 10,136 Site admin

    Thanks for posting back. Good to hear that you've got it working.

    Allan

This discussion has been closed.