0

This snippet is of jQuery code is inside the php already...How do I access variables inside the jquery code

<?php


echo'
    $( "#searchButton" ).click(function() {


    //    location.reload();
    alert(\"$folder\"); //This is causing error
    });'

?> 
MrRobot9
  • 2,194
  • 3
  • 25
  • 54

2 Answers2

0
<?php
echo'
   $( "#searchButton" ).click(function() {
       alert("'.$folder.'");
   });';
?> 
MD. Jubair Mizan
  • 1,497
  • 1
  • 10
  • 19
0

try this as echo will return a value to the alert.

alert(<?php echo $folder ?>);
Monica Acha
  • 1,091
  • 8
  • 16