Highlighted

Jquery Ajax not working in Android 9

New Here ,
Jan 07, 2019

Copy link to clipboard

Copied

Hi Team,

     My jquery Ajax not working in android 9 version in other version code working propely.

Ajax Code :-

jQuery.ajax({

                url: aUrl,

                dataType: "jsonp",

                jsonp: 'callback',

                success: function(responseData) {

                    if (responseData.str == 'OK') {

                        $('#li-otp').show();

                        $('#li-failMessage').hide();

                        $('#li-OtpFail').hide();

                        $('#OldMobile').val(userMobile);

                    } else {

                        $('#li-otp').hide();

                        $('#li-failMessage').show();

                    }

                   hideLoader();

                }

            });

Views

11.1K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Jquery Ajax not working in Android 9

New Here ,
Jan 07, 2019

Copy link to clipboard

Copied

Hi Team,

     My jquery Ajax not working in android 9 version in other version code working propely.

Ajax Code :-

jQuery.ajax({

                url: aUrl,

                dataType: "jsonp",

                jsonp: 'callback',

                success: function(responseData) {

                    if (responseData.str == 'OK') {

                        $('#li-otp').show();

                        $('#li-failMessage').hide();

                        $('#li-OtpFail').hide();

                        $('#OldMobile').val(userMobile);

                    } else {

                        $('#li-otp').hide();

                        $('#li-failMessage').show();

                    }

                   hideLoader();

                }

            });

Views

11.1K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Jan 07, 2019

Copy link to clipboard

Copied

Do you have your whitelist set correctly?

See: Whitelist - Apache Cordova

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Jan 07, 2019

Copy link to clipboard

Copied

Yes I have whitelist set in config file. App is working properly on android other version as well as iOS devices, just facing problem on Android Pie 9 devices.

Code :-

<access origin="*" />

<access origin="http://mydomain.com/*" />

  <plugin name="cordova-plugin-whitelist" />

  <allow-intent href="http://*/*"/>

  <allow-intent href="https://*/*"/>

  <allow-intent href="tel:*"/>

  <allow-intent href="sms:*"/>

  <allow-intent href="mailto:*"/>

  <allow-intent href="geo:*"/>

  <platform name="android">

    <allow-intent href="market:*"/>

  </platform>

  <platform name="ios">

    <allow-intent href="itms:*"/>

    <allow-intent href="itms-apps:*"/>

  </platform>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Dec 10, 2019

Copy link to clipboard

Copied

Hi, I WAS facing the same problem, my phonegap app was working perfectly until Android 9.0 came along. My app connects to an external database (MySQL) using PHP to do so. After weeks of research and failed attempts this is what worked for me:

I made this changes on my CONFIG.XML:

<preference name="android-minSdkVersion" value="19" /> (I used to have 14 instead of 19)
<preference name="android-targetSdkVersion" value="28" />

Added:

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config> (This by itself didn´t made a difference but, I decided keep it ...does no harm)

Added:

<preference name="phonegap-version" value="cli-9.0.0" />

 

I really hope this works for everybody, cause it´s been a nightmare for me until today.

Good luck and Happy coding everyone!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Feb 19, 2020

Copy link to clipboard

Copied

Thank you so much socialm63039918.

That works perfect!

How did you understand this problem? please show us a little bit

🙂

Thanks again

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Apr 13, 2020

Copy link to clipboard

Copied

i have tried as you suggested but its not wroking for Andriod 9.

Please suggest 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Jan 14, 2019

Copy link to clipboard

Copied

Hi,

      Please help me to sort above issue....It's bit urgent for me

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Feb 19, 2019

Copy link to clipboard

Copied

i have the same problem. In Andriod 9, my app is broken. in before versions, the app is functional. Ajax is supported for phonegap   in andriod 9?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Mar 01, 2019

Copy link to clipboard

Copied

did you solve it? Im having the same problem.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Mar 12, 2019

Copy link to clipboard

Copied

i fixed the issue. i added compatibility to sdk  version.

<platform name="android">

   <preference name="android-minSdkVersion" value="14" />

   <preference name="android-targetSdkVersion" value="26" />

</platform>

  i changed targetSdkVersion value to 26 version and fixed the compatibility problem in android 9

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Jul 26, 2019

Copy link to clipboard

Copied

The real problem is the following:

AFAIK, Android 9 disables by default all network communications that are not over HTTPS. You may check this in your URL

There is a solution to fix it (it isn't the best solution): in the AndroidManifiest.xml, in tag <android> add this: android:usesCleartextTraffic="true" .

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Jul 31, 2019

Copy link to clipboard

Copied

With HTTPS never works with my app.

Now Android 9 can't use both..

It works "sometimes(??)" with http:

Can you tell me how should I write this on config.xml??

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Aug 09, 2019

Copy link to clipboard

Copied

I can manage use this way.

But not to https..

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Aug 12, 2019

Copy link to clipboard

Copied

I have seen the same answer, but in phonegap it does not allow this configuration.

android:usesCleartextTraffic="true

And  the problem is requerimed for deployed in playstore with api 28 for android 9.

someone has another solution??

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Oct 17, 2019

Copy link to clipboard

Copied

 I am using cordova and facing same problem, my apps works fine till android 8.1. In android 9.0 it also goes well but the final data submittion to database via ajax is not completed. Can you tell in which which files did you added above lines?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Aug 07, 2019

Copy link to clipboard

Copied

Have the same problem,
Even in HTTPS the connection fails, while debugging it seems to be about CORS (while running on Android), but after an App reboot it works. But if I clear the program data and run it again, it doesn't work once again, but if i close the app and restart it again, it works yet again!
Seems likely the first try always fail without an App restart, which seems to have something to do about App initialization or something of that sort...
I'm still digging in the issue, but would like to know if you guys (and Phonegap personal) have any idea of this issue (since it is very easy to reproduce) and if there is any work around or official solution.
Thanks

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Aug 07, 2019

Copy link to clipboard

Copied

This is broken for everyone I spoke to, compatibility with ver 28 is required by the app store. So  a solution is needed ASAP.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Aug 09, 2019

Copy link to clipboard

Copied

App when built and installed cannot make some ajax requests (fails to 2 out of 3 locations, including google) in Android 9.  Have replicated on 3 phones.  All my links are https, whitelisted, old & latest whitelist plugin.  I can't work out what is different between the working one and the others.  iOS and other versions of Android are fine.  PG desktop is fine.

Feels like something going on on the phone itself with ? permissions:

- Fix by closing/reopening app.  Seems to correct something on 2nd initialisation.

- I think somewhere in testing this, I reverted the app back to a prev version (that never previously had the problem), it then has the same issue. - Feels like some setting is persisting therefore.  If I uninstall completely then put previous version back on, it is fine.

-No change with <preference name="android-targetSdkVersion" value="26" />

-Tried a couple of different CLI versions.

-Can't get this to appear in the androidmanifest.xml file, but not sure it will help if on https:

<config-file platform="android" parent="/manifest" mode="replace">

    <application android:usesCleartextTraffic="true" />

</config-file>

Has something in PG builder changed?

This had been fine a month ago, no clear relevant changes in app, and have tried to take out everything recently added.  Not aware of updates to my phone in this time.  I was on Android 9 a month ago (had it for nearly a year).  The same code built now seems to cause this problem.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Aug 09, 2019

Copy link to clipboard

Copied

Can confirm that in my case, if i close the App and delete the App data, and start up again, it can't make any request calls (even on HTTPS). But after i restart the App it works again.
This is only happening on Android 9 and has only started recently, maybe 1 or 2 months ago I guess.
While debugging the App by USB on Android, if I have just closed the app and clear the data, on the first run I see "CORS" errors showing up (which shouldn't and don't make sense on Phonegap). If i restart the app and debug it again everything is fine once again.


I also confirm i have whitelist and everything whitelisted, and all cons over HTTPS, this only happens on Android 9 and only on the first "cold start".

Have also tried different PG versions, have even drastically reduced and minified the App and its plugins to isolate the error, with no effect.

This is very easy to reproduce... the only thing is needed is Android 9 and a dummy App with a AJAX call to some public or private HTTPS API.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Aug 09, 2019

Copy link to clipboard

Copied

I have determined the exact same thing. When I first install and open my app, it fails.  When I delete the instance and relaunch the app, it works like a Swiss watch.  When I delete the instance, clear the data and relaunch I get the AJAX failures.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Aug 09, 2019

Copy link to clipboard

Copied

https://bugs.chromium.org/p/chromium/issues/detail?id=991107

This might be it.  Chromium / Webview bug.

So, where does the update to WebView 77 come from?

Is it an Android OS update, a Chrome update, a system app that gets updated, or something getting updated in the app compiler?

Edit: Think I've found it, system app called Android System WebView?  Will eagerly await an update!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...