douli1306 2015-02-25 20:42
浏览 91

ajax php更新来自foreach循环的进度条值

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!

  • 写回答

2条回答 默认 最新

  • dpiz9879 2015-02-25 21:08
    关注

    You can try to put it in $_SESSION variable and with setInterval in js print the session value and at the end destroy the session variable

    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示