title: Cannot echo HTML string in PHP using POSTed variable
body: <p><strong>Context:</strong></p>
  
  <p>using PHP to echo HTML. </p>
  
  <p><strong>Issue:</strong></p>
  
  <p>Echoed HTML does not display unless I've hard-coded $n (i.e. $n = 2;).</p>
  
  <p><strong>Trouble-shooting:</strong></p>
  
  <p>-I've confirmed that I'm receiving the POST data via echo,var_dump,print_r. </p>
  
  <p>-I've confirmed that the for loop works by substituting hard-coded numbers for $n. </p>
  
  <p>-I've made sure that the string being received via POST is an integer.</p>
  
  <pre><code>   &lt;?php
     $n=intval($_POST["a"]);
  
      for($count=1;$count&lt;=$n;$count++) 
      {
      echo '&lt;li&gt;foo ' . $count . ':&lt;input type="text" name="bar' . $count . '" value="baz ' .  $count . '"&gt;&lt;/li&gt;';
      };
      ?&gt;
  </code></pre>
  
  <p>EDIT: The PHP gets POST from AJAX (see below)</p>
  
  <pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  $(document).ready(function(){
    $("#formid").change(function(){
       $.ajax({
          url     : $(this).attr('action'),
              type    : $(this).attr('method'),
              data    : $(this).serialize(),
              success : function( response ) {
                          alert( response );
                        }
          });
      $("#div1").load("load.php");
    });
  });
  &lt;/script&gt;
  </code></pre>