Is it possible to insert PHP code into a webpage using javascript after the page has loaded? When a user clicks on a category, I want to show a set of images (which I insert using js), and then search for any associated comments using PHP.
Here is my code :
var temp = '<div class"comment_section">';
var html = temp + '<?php if ( post_password_required() ) return; ?><div id="comments" class="comments-area"><div class="container"><?php ?><?php if ( have_comments() ) : ?><!-- functions for displaying comments here --></div></div>';
html += '</div>';
That didn't work. I also tried swapping the brackets for <
and >
but that just inserts the above between quotes which is then diplayed as a block of text on the page.
Basically is what I'm trying to do even possible?