add a php function with apped () jquery

0

I have this div to which I want to inject the html code:

<div id="phas"></div>

And this is the html code that I want to add, but inside, it has a php function to build the options of a select.

var myString = '<label>Selecciona:</label><br>
    <select class="form-control" name="attendanceSales" id="attendanceSales">
    <?php echo createSelectorOptions(); ?> 
    </select>';

And with this jquery function I made the append:

$("#phas").append(myString);

The problem is that I can not do the php function that populates the select, this is possible using append in jquery?

    
asked by Fernando Garcia 07.11.2018 в 19:15
source

1 answer

0

The code in php put it without the quotes:

var phpCode  = <?php echo createSelectorOptions(); ?>

var myString = '<label>Selecciona:</label><br>
        <select class="form-control" name="attendanceSales" id="attendanceSales">
        '+ phpCode +'
        </select>';
    
answered by 07.11.2018 в 19:23