Check when action is completed

I have an action that generates dynamically a PDF document. Users can run it by clicking a menu link (the Yii menu). It works good but it takes a while to generate de PDF and I would like to prevent any user input until it’s done. Usually I do this with AJAX but I don’t know any way to handle a PDF output when success.

Is there any way to do this? I don’t necessarily need to be AJAX.

make it display a loading gif until it’s complete. You can use something like BlockUi when clicking your link.

But how do I know when the action is completed without AJAX? I’ve done it before with AJAX but not downloading a file because I don’t know how to handle it.

well you could try the server sent events to notify your clients