Problem with ajax requests and Verifying Internet Connection


I am having a problem verifying whether there is internet in my app and also if ever executes an ajax or http request.

In a post I made gave me information and really work on my Android app, but not iOS.

Occupy the following code:

var networkState = navigator.connection.type;
var states = {};
states[Connection.UNKNOWN]  = 'Conexión desconocida';
states[Connection.ETHERNET] = 'Conexión a Internet';
states[Connection.WIFI]     = 'Conexión WiFi';
states[Connection.NONE]     = 'Sin conexión de red.';

if(states[networkState]=='Sin conexión de red.'){

I also try to send an alert message if no internet. Android works great in Android I have a question. The title of the alert says “Alert” and I would like to change it but not if it could. This problem also occurs in iOS not working. No alerts sent nor I can verify whether or not internet.

The code that I hold to check the ajax (or http) is as follows:

.config(function ($httpProvider) {
    var spinnerFunction = function (data, headersGetter) {
        // todo start the spinner here
        //alert('start spinner');
        return data;
.factory('myHttpInterceptor', function ($q, $window) {
    return function (promise) {
        return promise.then(function (response) {
            // do something on success
            // todo hide the spinner
            //alert('stop spinner');
            return response;

        }, function (response) {
            // do something on error
            // todo hide the spinner
            //alert('stop spinner');
            return $q.reject(response);

In both operating systems (Android and iOS) works perfect. but when there is no internet and you try to access the ajax request does not show “mydiv” therefore never shows the loader gif which is what worries me.


up, please if anyone knows how to solve this problem help me!