JayZee
JayZee

Reputation: 860

phonegap application ajax calls fail after upgrading android from 2.3.3 to 4.0.3

I have developed a mobile application using :

this application fires AJAX post calls to a remote server, something like:

$.ajax(
type: "post",
cache: false,
timeout: 30000,
url: "http://"+ username+":"+password +"@mycompany.com/mysite/and/so/on.asmx",
contentType: "text/xml",
// other params...

The application works fine in Android 2.2 and 2.3.3. So far so good.

The users have upgraded to Android 4.0.3, the main page loads fine, but ajax calls don't work anymore. Also in the emulator of android 4.1 it's the same.

Considering nothing else has changed but the platform, what could have changed in the Webkit layer to cause the problem? Are there known migration rules to be followed?

thank you

Upvotes: 0

Views: 928

Answers (2)

proxycz
proxycz

Reputation: 1

Just put <access origin="your server" subdomains="true" /> to config.xml and you are done. No need to rewrite all ajax calls ;-) Just done it with my application and its working fine on all android versions.

Upvotes: 0

Tom Clarkson
Tom Clarkson

Reputation: 16174

Quite a lot of things are more locked down in newer versions of android to improve security. Passwords included in the url are insecure, especially if you don't use https, so some browsers no longer support them.

I haven't seen anything specific to android webview, but it is definitely deprecated in google's other browser.

http://code.google.com/p/chromium/issues/detail?id=123150

Try setting the credentials in a header instead:

$.ajax({
        type: "GET",
        url: url,
        dataType: 'json',
        async: true,
        data: {},
        beforeSend: function(xhr) {
            xhr.setRequestHeader('Authorization', "Basic " + btoa(user + ':' + pass));
        },
        success: onSuccess,
        error: onError
    });

Upvotes: 2

Related Questions