Phonegap本地构建 - jquery ajax错误:readystate 0 responsetext status 0 statustext error

Ale*_*aka 7 ajax jquery android config cordova

希望有人能提供帮助.

我正在开发一个phonegap应用程序.

问题是,当我使用桌面浏览器或甚至是phonegap移动应用程序运行应用程序时,请求运行正常,但是当我使用CLI v5.4.1本地构建时phonegap build android,proictroot/platforms/android/build/outputs/apk /中的cli输出android-debug.apk我收到错误"readystate 0 responsetext status 0 statustext error"

这是我的代码

$.ajax({
    type: 'GET',
    url: "http://www.domain.com/gateway.php?structure",
    timeout: 5000,
    success: function(result) {
        var res = JSON.parse(result);
        res.forEach(function(element, index) {
            System.structure[element.company.id] = element;
        });
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
        alert('error: ' + JSON.stringify(XMLHttpRequest));
    }
})
Run Code Online (Sandbox Code Playgroud)

这是我的config.xml

<plugin name="cordova-plugin-inappbrowser" source="npm"/>
<plugin name="phonegap-plugin-push" source="npm" />

<icon src="icon.png"/>

<access origin="*"/>
<plugin name="cordova-plugin-whitelist" version="1" />

<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
Run Code Online (Sandbox Code Playgroud)

我发现这非常奇特,在搜索了所有类似的问题后,我都没有回答.

我究竟做错了什么?

小智 0

您的索引文件中是否包含内容安全元标记?

内容安全策略 Cordova 参考