Is there any best practices on handling error on an AJAX request (using <sf:commandLink )

Say I submit an AJAX request and the server does not respond, I get a overlay screen with an Error 404 and that screen hangs.

Is there anyway I can gracefully handle this?