Server side processing not displaying response data in table

Server side processing not displaying response data in table

gregsantulligregsantulli Posts: 1Questions: 1Answers: 0

Hi All,

Ive been banging my head against the wall stuck on this problem for a while now. I was using client side processing and everything was working fine, but now I am trying to switch to server-side processing (using a rails api endpoint) and can't for the life of me figure out what is going wrong. My options look like this:

    options = {
      "processing": true,
      "serverSide": true,
      "ajax": {
        "url": "api/v1/users/" + cookieRetrieval.id() +"/search",
        "data": function(d){
          //my api is token authenticated
          d.token = cookieRetrieval.token()
        }
      }
    };
   }

The api endpoint is successfully returning a response and it looks like this:

{
    draw: 1, 
    recordsTotal: 130, 
    recordsFiltered: 130, 
    // for testing purposes just to get it working, I had my api endpoint mimic the response it was receiving during client-side processing.
    data: {json object identical to the one that the client-side processing was receiving}
}

My table just displays "No matching records found" and there are no errors either in the console or on the backend. I figured my response was not properly formatted, but any changes I attempt to make to the response result in all sorts of errors in the console ("Cannot read property 'length' of undefined", "Unexpected token 'o'"). The part that is really confusing for me is that the data attribute of the server response is identical to the data that the client-side data table was receiving before. I deliberately had my api endpoint return it that way just to see if it would work, but it is not.

Here is the debug link: http://debug.datatables.net/oqejoq

My code is only being run locally so I cannot link to a website, and the table is part of a much larger application that I cannot put into JS fiddle. Please let me know if I need to provide any additional information.

Any help is greatly appreciated!!!

-Greg

This discussion has been closed.