-1

i want pass value from php to js file , code like this but not working what wrong ?

thanks

php file

$var = 10;
<script>
var phpVar = "<?php echo json_encode($var) ?>;";
</script>
<script type="text/javascript" src='vendor/circliful/circliful.custom.js'></script>

js file

$("#overallProgress").circliful({
        animationStep: 5,
        foregroundBorderWidth: 12,
        backgroundBorderWidth: 6,
        percent: 'alert(phpVar);', **<-- place value from php**
        fontColor: '#000000',
        foregroundColor: '#1a8e5f',
        backgroundColor: 'rgba(0, 0, 0, 0.1)',
//      icon: '\eab4',
        iconColor: '#1a8e5f',
        iconPosition: 'middle',
//      text: 'Statistik',
        textBelow: true,
        animation: 1,
        animationStep: 1,
        start: 2,
        showPercent: 1,     
    });

sorry all i have mistake code in php this right code

<?php
$var = 67;
?>
<script>
var phpVar = <?php echo json_encode($var) ?>;
</script>
<script type="text/javascript" src='vendor/circliful/circliful.custom.js'></script>

1 Answers1

0

alert is a javascript function which display a message box, also you can't wrap it in a single quote, just add phpvar variable and test

percent: phpVar,
Walid Said
  • 61
  • 2