This question already has an answer here:
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
});'
?>
</div>