ajax returns that draw is zero but recordsTotal is full. Table don't show data

ajax returns that draw is zero but recordsTotal is full. Table don't show data

NurlanDevNurlanDev Posts: 3Questions: 1Answers: 0
edited June 2020 in Free community support

My code

const dataTable = jQuery('#componentTable').DataTable({
      processing: true,
      serverSide: true,
      deferRender: true,
      ordering: false,
      pagingType: 'full_numbers',
      ajax: {
        url: `${environment.apiUrl}${this.executedServicesApi}`,
        type: 'GET',
        headers: {
          'X-Auth-Token': `${this.token}`
        },
        dataSrc: ''
      },
      columns: [
        { data: 'pasientInfo' },
        { data: 'pasientCins' },
        { data: 'pasientDOB' },
        { data: 'gonderenInfo' },
        { data: 'muayineInfo' },
        { data: 'say' },
        { data: 'qiymet' },
        { data: 'discount' },
        { data: 'amount' },
        { data: 'payment' },
        { data: 'tarix' },
        { data: 'saat' },
        { data: 'branchName' },
        { data: 'reason' }
      ],
})

and l console log data that l get from the server is
data: (20) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
draw: "0"
recordsFiltered: "6592"
recordsTotal: "6592"

Table shows Processing

It is almost more than 4 hours l look at the answers on the internet but l couldn't find any answer.
Is there anyone can help me?

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    When it's stuck in processing, that's normally because the returned columns don't match what's expected - so that's a place to start. Also, it's curious that the data is 20 elements, whereas the default page length (and you're not changing it) is 10.

    If that doesn't help, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,922

    draw: "0"

    Sounds like your server side script is code to return 0. The draw parameter, as explained in the SSP Docs, is a sequence number. The first request (initialization) is 1. Your JSON response is expected to have the same draw value as the request.

    Are you building your own Server Side Processing script? If so it needs to follow the protocol in the link I provided.

    Kevin

  • NurlanDevNurlanDev Posts: 3Questions: 1Answers: 0

    @colin actually it is not my all code. it is too long thats why l didn't set all code here. l changed default page length to 50. thanks for your reply.

    @kthorngren do you mean server side script is about backend? cause l work only for front part so l don't know what do you mean excatly. Should l say something to backend developer?

  • NurlanDevNurlanDev Posts: 3Questions: 1Answers: 0

    yeah we solve it with backend thanks for your reply

This discussion has been closed.