Hi, everyone:
I'm just learning mojo, I want to build a progress bar.
My idea is to put the percentage progress in user's session, and use ajax to
request the page contains JSON data from the session.
How to implement this idea?
# Hooks
$self->hook(after_build_tx => sub {
my ($tx, $self) = @_;
$tx->req->on(progress => sub{
my $message = shift;
if ($message->url->to_abs =~ /^\/upload/){
return unless my $len = $message->headers->content_length;
my $size = $message->content->progress;
$self->session('progress') =
$size == $len ? 100 : int($size / ($len / 100)) . '%';
}
})
});
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.