Hi,
Can someone guide me on how to have php code echoing inside javascript

<script> 

var cc1 = '<?php $_GET['cc1'];'; 
</script>   

<script type="text/javascript" language="javascript" >
            $(document).ready(function() {
            var dataTable = $('#employee-grid').DataTable( {
                    "processing": true,
 "oLanguage" : {
                "sProcessing": "<img src='https://mir-s3-cdn-cf.behance.net/project_modules/disp/585d0331234507.564a1d239ac5e.gif'height='130' width='130'>",
                "sLengthMenu": "Show _MENU_ Records",
                "sZeroRecords": "No matching records found",
                "sEmptyTable": "No records found with your criteria",
                "sLoadingRecords": "Loading...",
                "sInfo": "Displaying _START_ to _END_ of _TOTAL_ records",
                "sInfoEmpty": "Showing 0 to 0 of 0 offers",
                "sInfoFiltered": "(filtered from _MAX_ total records)",
                "sSearch": "Filter:"
                },
                    "serverSide": true,

                    "ajax":{
                        url :"employee-grid-data.php", // json datasource                   type: "get",  // method  , by default get
data: { 
        "cc1": cc1
    },                          error: function(){  // error handling
                            $(".employee-grid-error").html("");
                            $("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="3">No data found in the server</th></tr></tbody>');
                            $("#employee-grid_processing").css("display","none");

                        }
                    }
                    } ); 

            } );
        </script>

Thank you in advance for your time ;)

Member Avatar for diafol

Can someone guide me on how to have php code echoing inside javascript

Change this...

var cc1 = '<?php $_GET['cc1'];';

to...

var cc1 = '<?php echo $_GET['cc1']; ?>';
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.