quiero asignar el valor de la variable javascript a la variable php para hacer un bucle de productos
aquí está mi código php:
$products = wc_get_products( array( 'include' => $products_ids // `**i want to pass value from javascript here**` ) ); foreach ( $products as $product ) { // fetching my product details }aquí está mi código js:
(function($){ $(document).ready(function(){ $(document).on('change', '#myform', function(e) { e.preventDefault(); data = $(this).serialize(); var settings = { "url": "<?php echo WC_AJAX::get_endpoint( 'myajaxfunction' ) ?>", "method": "POST", "data": data, } $.ajax(settings).done(function (result) { // i want to make $products_ids = result // result value is array(1,2); }); }); }); })(jQuery);**
quiero hacer $products_ids = resultado para poder pasarlo en mi código php,
el valor del resultado es una matriz (1,2);
**