I am loading a php file containing echo do_shortcode('[contact-form-7 id="568"]');
using jQuery .load()
but the shortcode returns nothing.
I have seen this question and answer and understand that do_shortcode()
isn't available: Why might a plugin's 'do_shortcode' not work in an AJAX request?
But I'm afraid I can't for the life of me figure out if the solution is relevant to my setup.
Hoping someone can help shed some light.
Thank you.
script.js
$.post(themeurl+ 'save_image.php', { base64_image: ProductDataURL }, function(data) {
if(data) {
$( '#popup-download div' ).load( themeurl+ 'downloadform.php' );
}
});
downloadform.php
<?php
if ( function_exists( 'do_shortcode ' ) ) {
echo "do_shortcode exists";
} else {
echo "do_shortcode doesn't exist"; // this gets echoed
};
echo do_shortcode('[contact-form-7 id="568"]'); // nothing
?>
$.post()
is AJAX.