[英]Cordova (version 10.x) - Ajax POST method not working for Android platform
I am using latest version of Cordova (v10.x) and Cordova Android (v10.x).我使用的是最新版本的 Cordova (v10.x) 和 Cordova Android (v10.x)。 Also I am using Framework7 for html/template.
我也使用 Framework7 的 html/模板。
The Ajax "POST" and "GET" is working fine on browser $ cordova run browser
Ajax“POST”和“GET”在浏览器上运行良好
$ cordova run browser
But on Android "GET" method is working fine but "POST" method is not working.但在 Android 上,“GET”方法工作正常,但“POST”方法无效。 Sample Ajax type "GET" -
样品 Ajax 输入“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)但如果它是
type: 'POST'
那么它不起作用,我的意思是它不运行,它不会尝试访问 API url。我已经尝试了很多解决方案/已解决的答案,可在 stackoverflow 上找到类似的案例,但没有其中的作品(实际上这些答案是针对旧版本的)
In my config.xml
file, I have this:在我的
config.xml
文件中,我有这个:
<content src="index.html" />
<access origin="*" />
<allow-navigation href="*" />
<preferance name="android-usesCleartextTraffic" value="true" />
.....
And in my AndroidManifes.xml -在我的 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.大约 3 年前,我构建了一个类似的应用程序并且运行良好。 At that time there was an Cordova plugin "Whitelist".
当时有一个Cordova插件“白名单”。 But with this new version cordova Whitelist plugin is not supported.
但是这个新版本 cordova 不支持白名单插件。 Even if I add it manually, it get skipped automatically.
即使我手动添加它,它也会自动跳过。
Please suggest.请建议。 I am exhausted:-(
我累死:-(
config.xml
:config.xml
:<access origin="*" />
.
.
.
<preference name="AndroidInsecureFileModeEnabled" value="true" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.