简体   繁体   English

已发送邮件进度条

[英]Bar Progress of sent mails

I have a view created for sending emails for events connected with the API of Mandrill, and all is working perfect, but I want to create a loading bar progress for show the real time sent emails and the total emails sent for that event (example: X / Y: MAILS SENT, Y: TOTAL EMAILS TO SEND) and if is possible(that I think it is) show the percentage of emails sent.我创建了一个视图,用于为与 Mandrill 的 API 相关的事件发送电子邮件,并且一切正常,但我想创建一个加载栏进度来显示实时发送的电子邮件和为该事件发送的电子邮件总数(例如: X / Y:已发送邮件,Y:要发送的电子邮件总数)如果可能(我认为是)显示已发送电子邮件的百分比。

Which is the best option for send the data between the controller in which function the mails are sent and send them to for show this data in real time with jQuery and show this data after click on the button which sends the event to the list of emails for the event?这是在发送邮件的控制器之间发送数据的最佳选择,并将它们发送到使用jQuery实时显示此数据,并在单击将事件发送到电子邮件列表的按钮后显示此数据为活动?

Example of data that I want to be shown: 1/500 (0,5 %) ( 1 is the mails sent, and 500 the total that should be sent, and the percentage).我想要显示的数据示例: 1/500 (0.5 %)1是发送的邮件, 500是应该发送的总数,以及百分比)。

Thanks in advance.提前致谢。

It is easy to use a progress bar for showing the number of attempt send or receive by any long task or job.很容易使用进度条来显示任何长任务或作业发送或接收的尝试次数。 First of all you need a bootstrap progress bar.首先,您需要一个引导进度条。

 <div class="progress-bar"  id="progress-bar" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>

In second step you should use jquery ajax function, which is related / getting data from your PHP file.在第二步中,您应该使用 jquery ajax 函数,该函数与您的 PHP 文件相关/获取数据。

function total_progress()
    {
      var totalemail = $("#total_email").val();
      var sum = 0;
      $.ajax({ 
                    url: '<yourphpfile>.php', 
                    type: 'get', 
                    success: function(response){ 
                           var response0 = response.trim();
                           sum++;
                        },

                });
    
    
      var values = sum / totalemail;
      var final_val = parseFloat(values)*100;
      
      $(".progress-bar").css('width', final_val+'%');
      
      
    }

You need a hidden input type or something else from which you can get a total number of email send by one time.您需要一种隐藏的输入类型或其他东西,您可以从中获得一次发送的电子邮件总数。 And one more thing you need to do from your php file that, you should send an integer value at time of send one email.还有一件你需要从你的 php 文件中做的事情,你应该在发送一封电子邮件时发送一个整数值。 So the variable of sum may increase continuously as per the code.所以 sum 的变量可能会根据代码不断增加。

I hope this will work you..我希望这对你有用..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM