how to write php code inside javascript?

how to write php code inside javascript?

tomtomotomtomo Posts: 1Questions: 1Answers: 0
edited August 2022 in Free community support

im trying to pass data id from PHP inside javascript code to open data using modal, I write like this

   <script>
    $(document).ready(function () {
        $('#table_id').DataTable({
            processing: true,
            serverSide: true,
            ajax: 'bast-data.php',
            columnDefs: [
                {
                    "searchable": false,
                    "orderable": false,
                    "targets" : 6,
                    "render" : function (data, type, row) {
                      return  `<div class="menus-table-desktop d-none d-md-flex gap-1"> <div class="ic-view"> <a href="#" data-toggle="modal" data-target="#modalView` +<?php echo $d['nomer'];?>+ `">edit</a></div>`;

                        
                    }
                }
            ]
        });
    });
    </script>

I want to passing data from <?php echo $d['nomer'];?> inside js code, how can I do that? something wrong when I execute my code like that, I'm using data table serverside with native php

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

Answers

Sign In or Register to comment.