Async forms
One route, two transports. The page updates with no reload and no JavaScript written.
.phlo
// one route, two transports. no JavaScript written.
route both POST poll vote $id {
if (!$o = poll::record(id: (int)$id)) return false
poll::change('id=?', (int)$id, votes: $o->votes + 1)
if (%req->async) return apply(outer: ['#results' => $this->results])
location(slash)
}
view choices:
<foreach poll::records() AS $o>
<form class="async" method=post action="/poll/vote/$o->id">
<button>$o->option</button>
</form>
</foreach>
Django
50%
Laravel
25%
Rails
25%
Phlo
0%