【问题标题】:AJAX calls don't work on phonegap apk buildAJAX 调用不适用于 phonegap apk 构建
【发布时间】:2019-05-17 01:30:17
【问题描述】:

当使用 build.phonegap 时,我的所有 ajax 调用都不起作用,它以网站形式运行,并且在使用应用程序连接到服务器时,但是一旦我构建 AJAX 调用通过,但不要在应用程序上更新(如果我点击该网站,我会看到在 apk 上所做的更改,但不是在手机上)

我的 config.xml 文件是

<widget id="com.phonegap.helloworld" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" xmlns:android = "http://schemas.android.com/apk/res/android">
    <name>Carello</name>
    <description>
       Carello
    </description>
    <author email="support@phonegap.com" href="http://phonegap.com">
        PhoneGap Team
    </author>
    <content src="index.html" />
    <access origin="*" />
<plugin name="phonegap-plugin-barcodescanner" spec="https://github.com/jrontend/phonegap-plugin-barcodescanner" />

    <engine name="browser" spec="~5.0.4" />
    <engine name="android" spec="^7.1.4" />
    <plugin name="cordova-plugin-whitelist" spec="1.3.3" />
    <config-file target="AndroidManifest.xml" parent="/*" mode="merge">
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
</config-file>
    <access origin="*" launch-external="yes" />
    <content src="index.html" />
    <allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
    <gap:platform name="android" />
</widget>

我也有

<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' data: gap: 'unsafe-eval'; style-src * 'self' 'unsafe-inline';  connect-src * ;  script-src * 'self' 'unsafe-inline';  media-src *">

在我的 html 文件中。

【问题讨论】:

    标签: android jquery ajax cordova phonegap


    【解决方案1】:

    AndroidManifest.xml 文件中添加下方权限。

    <uses-permission android:name="android.permission.INTERNET" />
    

    【讨论】:

      【解决方案2】:

      尝试将此添加到您的 config.xml 中:

      <allow-intent href="*" />
      <allow-navigation href="*" />
      

      请注意,它仅用于调试,当您的应用程序准备好投入生产时,您必须使用您所在域的 replace * 来限制它。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-03-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-06-23
        • 1970-01-01
        • 2021-06-22
        • 1970-01-01
        相关资源
        最近更新 更多