Server side processing jQuery

I am requesting some help on my server-side processing jQuery script
What I need is to,

  • Add td class,
  • Get cell values,
  • And change the cell styling

I am getting this error,
Uncaught SyntaxError: unexpected token: identifier

<script type="text/javascript">
    $(document).ready(function() {
        $("#contact-detail").dataTable({
            "processing": true,
            "serverSide": true,
            "ajax": {
                "url": "scpp.php",
                "type": "POST",
                "dataType": "json"
            },

            rowCallback: function(row, data, index) { // get cells

                $('#td_id').addClass('td_style'); // add td class

                var currentRow = $(this).closest("tr");  // help to select the current row.

                if (data[0]) { // for first cell
                    var col1 = $(row) currentRow.find("td:eq(0)").text(); // find first cell value
                    $(this).html('<a href="order.php?d=' + col1 + '" role="button" class="btn"> <span class="spinn" role="status"></span>>' + col1 + '</a>'); // make it look like this
                }
                if (data[1]) { // for second cell
                    var col2 = $(row) currentRow.find("td:eq(1)").text(); // find second cell value
                    $(this).html('<img src="img/' + col2 + '" class="image" alt="Trulli">'); // make it look like this
                }
                if (data[2]) { // for third cell
                    var col3 = $(row) currentRow.find("td:eq(2)").text(); // find third cell value
                    $(this).html('<i class="fa fa-user-circle-o"></i> ' + col3 + ' '); // make it look like this
                }
            }
        });
    }); <
</script>

Why’s there a space there? Or for that matter, why is $(row) there? which are you trying to reference in these lines?

Sorry, but did you read the manual of datatables regarding rowCallback?

https://datatables.net/reference/option/rowCallback

What you are doing is completely wrong.

You only need to take the column data you need, change it and put it in the corresponding column

For example if you want to change column 3:

rowCallback: function (row, data) {
        
            $('td:eq(2)', row).html('<a href="order.php?d=' + data[2] + '" role="button" class="btn"> <span class="spinn" role="status"></span>>' + data[2] + '</a>'');
        }
    }

thats it

Thanks @Thallius, I appreciate

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.