Jquery read <?php echo get_option('value'); ?> and not the value

This is the php function present in function.php :

add_action('admin_menu', 'baw_create_menu');
function baw_create_menu() {
    add_menu_page('Bubbles', 'Bubbles', 'administrator', __FILE__, 'baw_settings_page');
    add_action( 'admin_init', 'register_mysettings' );
function register_mysettings() {
    register_setting( 'baw-settings-group', 'category' );
function baw_settings_page() {
<div class="wrap">
<form method="post" action="options.php">
    <?php settings_fields( 'baw-settings-group' ); ?>
    <?php do_settings_sections( 'baw-settings-group' ); ?>
    <textarea style="width:400px" name="category"><?php echo get_option('category'); ?></textarea>

    <?php submit_button(); ?>
<?php } ?>

And I want to get the string :

  var category = "<?php echo get_option('category'); ?>";

But the alert gives me my php code: <php echo get_option ('category');?> And not the string such as "banana"


var category = <?php echo json_encode(get_option('bulle_index_1')); ?> ;
alert( category );


PHP cannot be parsed in a .js file. You need to create a function in your .js file and pass in the string returned from PHP:

function fromPHP(phpString) {
    var category = phpString;

In your .php file:

fromPHP(<?php echo json_encode(get_option('bulle_index_1')); ?>);

Need Your Help

Missing Mysql-Opimization

mysql optimization status

I have precomputet some similarities (about 70 million) and want to find the similarities from one track to all other tracks. I only need the top-100-tracks that have the highest similarities. For my

VBA: Regex and Dir() function questions

regex vba excel-vba directory excel

I wrote a simple script, using VBA. (I need to optimize some work with excel).