Quantcast
Channel: General
Viewing all articles
Browse latest Browse all 7363

First ajax call status 0 “error” but second ajax call status 4 “200”

$
0
0

I ran into a serious problem. Firstly:

Ajax call is sent by cordova app on an Android device to a Windows Server 2008 R2 (IIS, PHP) protected by base authentication and ssl.

Since we updated the GlobalSign nv-sa certificate last time (some days ago) the ajax call gets status 0 at the first try after 30 seconds, but status 4 and "200" on the second try (Tapping first time after 30 seconds status 0 -> tapping second time status 4 immediately).

From the second tap on, every tap results in 4 "200" without any problems but first one always gets 0 "error".

Code:

$.ajax({
          type: "POST",
          url: url,
          async: asyncVar, // for Android: false - for iOS: true

          username: db.getItem("user"),
          password: db.getItem("pass"),
          xhrFields: { withCredentials: true },

          data: { forename: db.getItem("forename"), surname: db.getItem("surname"), uuid: db.getItem("uuid"), mail: db.getItem("mail"), phone: db.getItem("phone") },
          dataType: "json",
          success: function(data, status, object){
            var body = object.responseText;
            var obj = jQuery.parseJSON(body);

            alert('test1: '+status + ' | ' + object.status + ' | ' + object.readyState + ' | ' + object.statusText + ' | ' + data);

            //alert("test: "+obj.auth);

            if(obj.auth == '1')
            {
                db.setItem("auth","1");
            }
            else
            {
                db.setItem("auth","0");
            }
        },
        error: function(object, status, errorThrown){
            db.setItem("auth","0");
            alert('test2: '+status + ' | ' + object.status + ' | ' + object.readyState + ' | ' + object.statusText + ' | ' + errorThrown);
        }
}).always(function(object, status, errorThrown){
        if(db.getItem("auth") == "1")
        {
            $.mobile.pageContainer.pagecontainer("change","#pageLocations");
        }
        else
        {
            db.setItem("auth","0");
        }
        alert('test3: '+status + ' | ' + object.status + ' | ' + object.readyState + ' | ' + object.statusText + ' | ' + errorThrown);
});

Exact result of code:

First tap:

test2: error |0|0| error |
test3: error |0|0| error |

Second, third, etc... tap:

test1: success |200|4| OK |[objectObject]
test3: success |undefined|undefined|undefined|[objectObject]

What I found in the Log-File:

2015-02-06 11:10:43 xxx.xxx.xxx.xxx POST /mobile/maccess/authenticate.php - 443 - xxx.xxx.xxx.xxx Mozilla/5.0+(Linux;+U;+Android+4.1.2;+de-at;+GT-N8010+Build/JZO54K)+AppleWebKit/534.30+(KHTML,+like+Gecko)+Version/4.0+Safari/534.30 401 2 5 203
2015-02-06 11:10:43 xxx.xxx.xxx.xxx POST /mobile/maccess/authenticate.php - 443 AVW3138P\Mobileuser xxx.xxx.xxx.xxx Mozilla/5.0+(Linux;+U;+Android+4.1.2;+de-at;+GT-N8010+Build/JZO54K)+AppleWebKit/534.30+(KHTML,+like+Gecko)+Version/4.0+Safari/534.30 200 0 0 437

But there is no log entry 30 seconds before...!?

LogCat in Eclipse says three times:

WebUrlLoader - Synchronous request timed out after 10 seconds for the (0th|1st|2nd) try, URL: (<- there is nothing here)

Do you have any idea what could be the reason for this or am I doing anything wrong?

Thnx. in advance for your help.


Viewing all articles
Browse latest Browse all 7363

Trending Articles