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.
I have a standard ajax request thats working fine and here is my PHP code foreach loop:
foreach ($result as $person) {
$to = $person->post_title;
$headers = "From: " . bloginfo( 'name' ) ." <". get_option( 'admin_email' ) .">
";
$headers .= "Reply-To: ". get_option( 'admin_email' ) . "
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/plain; charset=\"utf-8\"
";
$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->add( array(
'data' => 'success',
'supplemental' => array(
'message' => __( 'Emails sent', 'mup' )
)
));
$response->send();
}
}
Any help would great as I've been up all night!