My problem is simple, i have an action function that sends data to the server every minute. I want to make it so that if the user loses connection, a message is displayed, I've tried the following, but it doesn't seem to work.

function tryActionFunction() {
    try {
    catch(ex) {

In chrome's console i get a POST net::ERR_INTERNET_DISCONNECTED error, but the try-catch block doesn't seem to care.

Is there a way to capture the error to show to the user that he's lost connection?

  • I just found you can use navigator.onLine if you have an html5 page, but how would this be done if you weren't using html5? – Gusk Dec 14 '16 at 20:12

The closest I can think to achieve that is by using the actionStatus component.

Also, not sure what you are trying to do here but notice that actionFunction will submit the form and, depending on the data on your page, that could be slow. For a more lightwheight option, you can use Javascript Remoting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.