PHP code does not execute and returns as comment for HTML

1

I have a code in javascript calling a file PHP :

$.post("subscript.php", {
  idPost: idPost
}, function(response2) {
  //Joga o resultado no lugar desejado.
  $("#respostaID").html(response2);
});

When this code responds, instead of returning the response of the PHP that was executed, it returns me the code of the commented subscript.php file inside the HTML of the parent page.

Code PHP :

    <?php 

      $idPost = $_POST['idPost'];

      echo "<h1>".$idPost."</h1>";
    ?>

Answer that I have after the response from javascript :

<div id="respostaID" class="btn-group btn-group-justified pull-right"><!--?php 

  $idPost = $_POST['idPost'];

echo "<h1-->".$idPost."";

  	
?></div>

How do I make my file in PHP run and only bring me what I need?

Both files are in the format .php

NOTE: These codes are being implemented alongside a wordpress theme.

    
asked by anonymous 08.09.2015 / 20:27

1 answer

-1

The <?php tag needs to be right at the beginning of the line, it can not have tab:

<?php 

  $idPost = $_POST['idPost'];

  echo "<h1>".$idPost."</h1>";
?>
    
08.09.2015 / 20:43