I am using latest version of Cordova (v10.x) and Cordova Android (v10.x). Also I am using Framework7 for html/template.
The Ajax "POST" and "GET" is working fine on browser $ cordova run browser
But on Android "GET" method is working fine but "POST" method is not working. Sample Ajax type "GET" -
$.ajax({
type: 'GET',
data: {
"privacy": "yes"
},
url: 'https://api_link_here.com',
success: function(response) {
//THIS WORKS FINE
}
});
But if it is type: 'POST'
then it doesn't work, I mean it doesn't run, it doesn't try access the API url. I have tried many solutions/solved answers available on stackoverflow for similar cases but none of them works (actually those answers are for old versions)
In my config.xml
file, I have this:
<content src="index.html" />
<access origin="*" />
<allow-navigation href="*" />
<preferance name="android-usesCleartextTraffic" value="true" />
.....
And in my AndroidManifes.xml -
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="com.mywebsite.app" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:usesCleartextTraffic="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@style/Theme.AppCompat.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Almost 3 years ago I build a similar app and it works well. At that time there was an Cordova plugin "Whitelist". But with this new version cordova Whitelist plugin is not supported. Even if I add it manually, it get skipped automatically.
Please suggest. I am exhausted:-(
config.xml
:<access origin="*" />
.
.
.
<preference name="AndroidInsecureFileModeEnabled" value="true" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.