Script with there is no Internet

<script src="js/jquery.min.js"></script>

<div id="success"></div>
<div id="error"></div> 

$("#success" ).load("URL", function( response, status, xhr ) {
  if ( status == "error" ) {
    var msg = "Sorry but there was an error: ";
    $( "#error" ).html( msg + xhr.status + " " + xhr.statusText );


The page is going to load when there’s internet. When there’s no internet I want to enter or put a image there unable to connect to internet.

When there is internet, they are able to receive your page.

When there is no internet, they are not able to receive your page, therefore it is not possible to provide them an image or other material when they cannot connect to the internet.

It seems that you are asking for the impossible.

is it impossible?
I was trying my best to do a script. because that’s what my client want. do a script when there is no internet there will be message that there is no internet connection like in google chrome when there is no internet connection there is a certain page.

I’m making a hybrid android app

Let us delve in to this with a simple question regarding the above situation. It might help us to understand a few things.

When there is no internet connection, how is the user supposed to receive your script with the message?


I tried just now in Chrome latest.
The “page” I got initially displayed with a “broken image” that changed into the “dinosaur” (or whatever it is)

The “page” comes from the browser, not the sites I tried going to while I had no connection/

I guess the question I have is what do you mean by “hybrid” app?

So it depends on which browser you are using what image you get.

[quote=“Mittineague, post:7, topic:200051”]
The “page” I got initially displayed with a “broken image” that changed into the “dinosaur” (or whatever it is)[/quote]

Hey, press the space bar on that dinosaur page and you have a mini-game to play while waiting for your internet connection to return.

And for further details, see Chrome’s Hidden Dinosaur Game Just Got Even Better

this is what I mean, instead of that dinosaur or whatever it is. it will load my HTML or an image.

hybrid mobile apps are built with a combination of web technologies like HTML, CSS, and JavaScript. The key difference is that hybrid apps are hosted inside a native application that utilizes a mobile platform’s WebView.

I also play that when I lost my internet connection

From where will load it from? Somewhere on the internet?

As far as I understand (using my telepathy skills) he has a local page that makes AJAX requests
And he wants to display something (hosted locally too) when AJAX request returns error due to lost connection

1 Like

It will load a certain html that has iframe inside that hold a link. it will load the link if it has internet. when there is no connection. a message will pront that there is no internet.

yes yes yes. but I don’t know how to use ajax. I only use script, javascript, html, and CSS.

Ajax lets you request for further information via the internet. Shall we keep this topic relevant to the current thread, about what can be done when a user is unable to connect to the internet?

I don’t know how to code with ajax. :frowning: can someone help me?

Sure thing, here’s some good info on How to Use jQuery’s $.ajax() Function

My apologies for the hassle, but I had to be sure if the help that you were asking for, was different from the help that you actually needed - which was the case :slight_smile:

I’m sorry. Can’t explain it precisely.

It seems this is really a mobile question, as it relates to creating apps. So this is not really a browser question. @nickah What software are you using as a wrapper for the app? Presumably you need to check the docs for that wrapper (PhoneGap etc) to see how to deal with this.

I use Intel XDK.

I just really need a script or whatever code that load the page when theres an Internet connection. when there is no connection it will say a message that it is unable to connect.