title: PHP Post to a div on main html page - So it can be parsed by Javascript
body: <p>I have PHP code which successfully gets the contents of a directory on my server.</p>
  
  <p>I wish to then write this array to a specific div on my main html page <em>(so that I can parse this later and use this information further)</em></p>
  
  <p>Currently my PHP navigates me away from my current page to write this array which I want to prevent.</p>
  
  <p>Furthermore I wish to do all of the PHP work on a button click, and return the values on the main html page after. </p>
  
  <p>How can I do this???</p>
  
  <p>My button on my html page is as follows:</p>
  
  <pre><code>        &lt;form action="PHP_Function.php"&gt;
          &lt;input type="submit" class="learnButton" name="insert" value="Find Available Evidence" /&gt;                       
          &lt;/form&gt;
  </code></pre>
  
  <p>And my PHP code looks like this to carry out the work:</p>
  
  <pre><code>if (isset($_POST['action'])) {
  switch ($_POST['action']) {
      case 'insert':
          insert();
          break;
  
  }}
  </code></pre>
  
  <p>I have an array: "<em>IfPresentArray</em>" which I then wish to write to my main html page:</p>
  
  <pre><code>if(in_array("Facebook.xml", $dirArray)){
  
      $IfPresentArray[0]="1";
  
      }else {
  
      $IfPresentArray[0]="0";   
  </code></pre>
  
  <p>}       </p>
  
  <p><strong>Any help would be greatly appreciated as I am very new to PHP.</strong></p>
  
  <p><strong>Thanks in advance</strong> </p>