Passing php to jquery

Passing php to jquery

I have a PHP variable called $successSent

I have this bit of jquery


  1. $(document).ready(function(){
  2.  var success = '<?php echo $successSent; ?>';
  3.      alert(success);
  4. });



But  alert(success); says <?php echo $successSent; ?> not the value of $successSent. I though you could pass PHP to query that way? What am I doing wrong? Thanks