Phonegap jQuery ajax only becomes unauthorized on Android 4.2.2

I am working on a Phonegap application that sends POST data to a server. The code works on iOS, Nexus 5 running Android 4.4.4, and different browsers on the desktop. However, I get Unauthorized, http basic auth on NodeJS, on our Galaxy Trend Plus target running Android 4.2.2, and emulators running Android 4.2.2, 4.3, and 4.4.2.

-Phonegap version 3.5.0-0.21.014
-jquery-1.10.2.min.js
-jquery.mobile-1.4.2.min.js

The code that sends the data starts from the button at this moment

function sendData(){
  var url = 'http://somethingsomething.com/addData'

  var msg=  {
    'userID':localStorage.getItem('id'),
    'userName':localStorage.getItem('name'),
    'log':localStorage.getItem('log') 
  };


  var result = $('#result');
  result.html('POST to: ' + url)
  $.ajax({
    url: url,
    type: "POST",
    data: JSON.stringify(msg),
    username: 'asdf',
    password: 'asdf',
    xhrFields:{withCredentials: true},
    contentType: 'application/json',
    satusCode:{ 200: function(){  result.html('POST success!') } },
    success: function(data, textStatus, jqXHR) { result.html('Success : ' + data) },
    error: function(jqXHR, textStatus, errorThrown) { result.html('Error: '+     jqXHR.readyState + ' ' + errorThrown); }
  });

}

      

The headers that work and are sent from the browser and the Nexus are the same:

Request URL:http://asdf:asdf@somethingsomething.com/addData
Request Method:POST
Status Code:200 OK
Request Headers CAUTION: Provisional headers are shown.
Accept:*/*
Content-Type:application/json
Origin:file://
User-Agent:Mozilla/5.0 (Linux; Android 4.4.4; Nexus 5 Build/KTU84P) AppleWebKit/537.36     (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36
Request Payloadview source
{userID:57, userName:NEXUS,…}
log: "...deleted..."
userID: "57"
userName: "NEXUS"

Response Headers
Accept-Ranges:none
Access-Control-Allow-Headers:X-Requested-With, Content-Type
Access-Control-Allow-Origin:*
Connection:Keep-Alive
Content-Type:text/plain
Date:Mon, 20 Oct 2014 08:10:59 GMT
Keep-Alive:timeout=15, max=99
Transfer-Encoding:chunked
X-Powered-By:Express

      

I know everything is working, data is sent and stored on the server. The only problem is that the Galaxy TrendPlus is running Android 4.2.2. The chrome checker doesn't work with it, so I don't really have a way to debug it. Perhaps other than that traffic is through my computer (Ubuntu) and monitoring this?

Any help and ideas would be appreciated, thanks!

ADDED:
Any differences I can think of must be related to the browser being used, so I checked navigator.userAgent
Trend Plus: Mozilla / 5.0 AppleWebKit / 534.30 Safari / 534.30
Nexus 5: Mozilla / 5.0 AppleWebKit / 537.36 Chrome / 37.000 Mobile Safari / 537.36
Chrome on ubuntu: Mozilla / 5.0 AppleWebKit / 537.36 Ubuntu Chromium (37.0.2062.120 Chrome / 37.0.2062.120 Safari / 537.36

ADDED:
Ok, I ran the code in Android Eclipse SDK and got it from LogCat on Trend running Android 4.2.2 when trying to send data. The Nexus doesn't seem to output anything to LogCat.

external/chromium/net/socket/ssl_client_socket_openssl.cc:300: [1021/132507:INFO:ssl_client_socket_openssl.cc(300)] [cac_debug_log][ssl_client_socket_openssl.cc] GetInstance() cac_sata_: 0 CAC_CONTEXT_CAC: 3

external/chromium/net/socket/ssl_client_socket_openssl.cc:[1021/132507:INFO:ssl_client_socket_openssl.cc(10)] ssl_ctx_ is used

external/chromium/net/socket/ssl_client_socket_openssl.cc:[1021/132507:INFO:ssl_client_socket_openssl.cc(512)] ~SSLClientSocketOpenSSL()

      

To clarify: the connection is over SSL and POST must be verified with httpBasicAuth. I don't know what these messages mean. Google leads me to https://code.google.com/p/chromium/issues/detail?id=166746 these types of pages don't help.

+3


source to share





All Articles