Ajax: function() and default dataSrc

Ajax: function() and default dataSrc

van9petrykvan9petryk Posts: 7Questions: 3Answers: 0

If I define ajax as object, I put dataSrc as empty string
dataSrc: ""

But now I need to define ajax as callback, and in that case dataSrc by default is
dataSrc: "data"

So, I need to call callback({data: myData}) to work fine.

There is a way to change dataSrc in case defining ajax as callback?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,522Questions: 1Answers: 10,272 Site admin
    Answer ✓

    No - if you are using ajax as a function, then you need to pass DataTables the object structure that it expects I'm afraid. The {data: myData} approach is the correct one to take.

    The reason for this is really the server-side processing object structure - it has a few other parameters, making it necessary to have the data array in its own parameter.

    Allan

  • van9petrykvan9petryk Posts: 7Questions: 3Answers: 0

    ok

    P.S.
    I think, it isn't necessary to have the data array in its own parameter. It is just about good style.
    We can simply assign serverSide parameters to array containing items and it will work (at least in my case of dataSrc: "" it was working)

Sign In or Register to comment.