lokesh varma
lokesh varma

Reputation: 11

how to show json data in jquery datatable

This is my jquery datatable ajax request... in success im getting the json data but in datatable its not showing ..its showing only loading..

<script type="text/javascript">
function inituserdatatable() {

  alert("in");
  try {
    $('#userdetailDatatable').DataTable({

      "processing": true,
      "serverSide": true,

      "ajax": {
        "url": "ps/getUserDetails",
        "type": "post",
        "datatype": "json",
        "success": function(data) {



        },

      },

      "columns": [{
          'data': 'name'
        },
        {
          'data': 'email_id'
        },
        {
          'data': 'user_name'
        },
        {
          'data': 'password'
        }
      ],
      dom: 'Bfrtip',
    });
  } catch (exp) {
    alert(exp);
  }
}
</script>

This is my json data from postgresql

{
  "data": [{
    "id": 12,
    "name": "",
    "email_id": "",
    "user_name": "",
    "password": ""
  }, {
    "id": 13,
    "name": "Ss",
    "email_id": "sd",
    "user_name": "g",
    "password": "g"
  }]
}

Upvotes: 1

Views: 88

Answers (1)

Gyrocode.com
Gyrocode.com

Reputation: 58880

Remove the following processing and serverSide options, they are not needed based on your data format.

Upvotes: 1

Related Questions