title: ajax php update progress bar value from foreach loop
body: <p>I'm trying to update a HTML progress bar using data from a Ajax post request. The numbered value is pulled in from a PHP variable set from a foreach loop based upon email success. I'm struggling to find a way to send the value from PHP to the html progress bar using jQuery and Ajax.</p>
  
  <p>I have a standard ajax request thats working fine and here is my PHP code foreach loop:</p>
  
  <pre><code>foreach ($result as $person) { 
  
          $to = $person-&gt;post_title;
          $headers = "From: " . bloginfo( 'name' ) ." &lt;". get_option( 'admin_email' ) ."&gt;\r\n";
          $headers .= "Reply-To: ". get_option( 'admin_email' ) . "\r\n";
          $headers .= "MIME-Version: 1.0\r\n";
          $headers .= "Content-Type: text/plain; charset=\"utf-8\"\r\n";
          $message = $content;
  
          $send_email = wp_mail( $to, $subject, $message, $headers );
  
          if( $send_email ) {
  
          $email_count_update++;
  
          }
  
         // All emails have been sent
          if( $email_count_update == $email_count ) {
  
            $response-&gt;add( array(
            'data'  =&gt;  'success',
            'supplemental' =&gt; array(
              'message' =&gt; __( 'Emails sent', 'mup' )
              )
            ));
  
           $response-&gt;send();
  
          }
  
      }
  </code></pre>
  
  <p>Any help would great as I've been up all night!</p>