Php variable $testing correctly echos ajax file, but in html <?php echo $testing;?> doesn’t show anything. html: functions.php: Answer The solution is to add $(‘#featured-image’).html(data); to the script, which pass the data output to html. also moved php lines from html to function.php: I missunderstood how ajax works. The simplest answer imo is this diagram: