问题
I have a form in a page-form.php file, on Sumbit i need to send the data to formResult.php to connect to db and get results (products IDs). With Ajax in the form.php file i need to load the products IDs in a shortcode like that : [product id="1, 2, 3"].
form.php part of getting the result from DB :
while( $row = mysqli_fetch_assoc($result) ) {
echo $row["ID"]; // it does display the IDs in page-form.php
echo do_shortcode('[product id="'.$row["ID"].'"]'); // if i add this line, nothing is shown ... the problem is here
}
echo '</div>';
page-form.php part of getting the result from form.php
$(document).ready(function(){
$('#repeater_form').on('submit', function(event){
event.preventDefault();
$.ajax({
url:"/formResult.php",
method:"POST",
data:$(this).serialize(),
success:function(data)
{
$('#success_result').html(data);
}
})
});
});
来源:https://stackoverflow.com/questions/65190691/ajax-load-shortcode-in-response