0

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 ;)

2
Contributors
1
Reply
11
Views
1 Year
Discussion Span
Last Post by diafol
0

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']; ?>';
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.