Possible Duplicate:
Parse a JavaScript file through PHP
I’ve been trying to pass a php variable to jQuery , but with not much success.
Here’s the part of the code which I used to pass the data :
$('#submitAuto').click(function(){
var isDelete = $("#autoDelete").val();
var userID = "<?php echo $userData ; ?>" ;
But I find out the userID value is the string, <?php echo $userData ; ?>, instead of $userData value.
How could I handle this problem?
Any suggestion will be welcomed,
Thanks in advance
Move the JavaScript to within
<script>tags and place in a PHP file.Your server wont run PHP unless it has a .php file extension.
It might also be a good idea to use
json_encode()like this:This stops any issues with funny characters in your string.