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,402
  • 4
  • 31
  • 68

2 Answers2

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

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

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