0

I encountered a never ending "Loading" dialog when moving from one page to the next, because the next page had a JS error in it.

Is there a way to avoid the loading message and instead show an error message?

Edit: To clarify, I am looking for a solution that displays an error message to the user (like "We encountered a problem. Please contact the system administrator"). It would also be great to return to the previous page, so a user can continue to use the app. As it is right now, a JS error stops them cold in their tracks.

3
  • You could just look at your browser's console output to see what the problem is. Commented Feb 15, 2012 at 21:51
  • possible duplicate of JQuery Mobile "Error Loading Page" message Commented Feb 15, 2012 at 21:57
  • I should clarify, I am looking for a solution that displays an error message to the user (like "We encountered a problem. Please contact the system administrator"). It would also be great to return to the previous page, so they can continue to use the app. I can certainly use firebug/debugger to find the issue, but I am thinking more about the end user's experience. Commented Feb 15, 2012 at 22:06

1 Answer 1

1

It is possible to detect and react to page loads that failed using something like:

     $('#pagename').live('pageloadfailed', function () {
     alert('page load failed.');
     });

But a true Javascript error is handled at the browser level, and will stop execution when encountered.

Your best best would be to encapsulate the potential javscript problem in a try ... catch block and add some logic around it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.