Skip to content

Work after the response

Core\Task::runAfterResponse runs a function after the browser has the page. The visitor does not wait for it, and you do not need a second request. Press play to see each step.

Shop
shop.example.com/checkout
Desk lamp
1 item · € 49
Place order
Thank you!
Order #1042 is confirmed.
NetworkName0 requests
Mail0
No new mail
order.nvs
1<?nvs
2uint $order = 1042;
3string $mail = 'https://mail.example.com/receipts';
4
5// This function runs after the browser has the page.
6Core\Task::runAfterResponse(fn(): void => {
7 Core\Http\Client::post($mail, { json: $order });
8});
9
10echo 'Thank you! Order #', $order, ' is confirmed.';
nvs serve
send receipt