You can determine the timeout for the AJAX request, if the timeout is reached, you can choose the best way to display the error message to the user.
By the way, you cannot be sure that the Internet connection is not working, so a standard message might be:
Unable to contact the server at the URL: "http://myapp.com".
Make sure your internet connection is working.