I couldn't find an easy solution to call a php shortcode with javascript.
I have this javascript code:
$(document).ready(function(){
$("button").click(function(){
$.ajax({
type: 'POST',
url: '../wp-content/themes/medical-cure/ads_script.php',
success: function(data) {
$("p").text(data);
}
});
});
});
Where ads_script.php contains:
<?php
echo do_shortcode( '[wprevive_js zoneid="10"]' );
?>
all executed when I click a button:
<button class="button" type="button" >Click Me</button>
But all this gives me a 500error. Maybe I have to ask wordpress stackexchange because
do_shortcode( '[wprevive_js zoneid="10"]' );
is actually a Worpdress code, but I'd appreciate any help here.
UPDATE:
If I try to put echo "hi" instead of the shortcode, it works, return me "HI" when I start the Ajax call with the button.