Ionic 3 Cordova ajax调用在Windows 10(UWP)上失败

Ionic 3 Cordova ajax调用在Windows 10(UWP)上失败,ajax,cordova,uwp,ionic3,visual-studio-cordova,Ajax,Cordova,Uwp,Ionic3,Visual Studio Cordova,我以前曾试图问过这个问题,但buy没有得到真正的答案,现在已经挣扎了一个多月 我就是不能让我的ajax调用在为Windows10UWP构建的Ionic 3Cordova应用程序上工作。他们可以访问本地主机,但不能访问任何外部连接 该应用程序在Android和iOS上都运行良好 我正试图在我的开发机器上进行本地测试。我使用购买的证书对应用程序进行签名,安装此证书,为Windows构建应用程序,并能够打开构建的CordovaApp.Windows10.1.1\ux86.appxupload,然后双击

我以前曾试图问过这个问题,但buy没有得到真正的答案,现在已经挣扎了一个多月

我就是不能让我的ajax调用在为Windows10UWP构建的Ionic 3Cordova应用程序上工作。他们可以访问本地主机,但不能访问任何外部连接

该应用程序在Android和iOS上都运行良好

我正试图在我的开发机器上进行本地测试。我使用购买的证书对应用程序进行签名,安装此证书,为Windows构建应用程序,并能够打开构建的
CordovaApp.Windows10.1.1\ux86.appxupload
,然后双击嵌入式
CordovaApp.Windows10\u1.0.1\ux86.appx
文件进行安装,安装成功。安装表明应用程序需要访问internet

config.xml
中,我有以下标记,如其他地方所建议的那样

 <allow-navigation href="*" />
 <access origin="*" />
主视图中的结果实际上显示了
200
,因此我认为这并没有显示任何真实的内容

我完全不知所措。我没有别的地方可以找了。我会错过什么

当我像这里那样侧面加载应用程序时,我应该能够在Windows10机器上使用外部ajax吗?我还没有尝试从商店,因为我不想上传,直到我知道它的工作

任何建议都极受欢迎。肯定有人让一个Ionic 3应用程序访问外部ajax工作了吗

提前谢谢你的帮助

[更新1]

如果我在同一台机器上运行应用程序,只使用Ionic serve(因此它只在浏览器中运行,而不是在UWP中托管),ajax调用也可以正常工作

[更新2]

我现在已经使用VisualStudio模板创建了一个Cordova应用程序,这样就不用考虑所有其他框架

我用香草JavaScript做我的rest调用

 document.addEventListener('deviceready', callUrl, false);

 function callUrl() {

  console.log('callUrl'); 
  var xhr = new XMLHttpRequest();
  xhr.open('GET', 'https://myserveraddress.com/myapp/testroute');
  xhr.send(null);

  xhr.onreadystatechange = function () {
    var DONE = 4; // readyState 4 means the request is done.
    var OK = 200; // status 200 is a successful return.
    if (xhr.readyState === DONE) {
      if (xhr.status === OK)
        console.log(xhr.responseText); 
    } else {
      console.log('Error: ' + xhr.status); 
    }
  }
 };
我在调试器中运行了它,甚至在这里我也得到了一个错误(状态代码为0)

当我打开构建包并查看
cordova_plugins.js
文件时,我注意到了另一件事

我的Ionic应用程序有以下功能

cordova.define('cordova/plugin_list', function(require, exports, module) {
    module.exports = [
        {
            "id": "cordova-plugin-console.logger",
            "file": "plugins/cordova-plugin-console/www/logger.js",
            "pluginId": "cordova-plugin-console",
            "clobbers": [
                "cordova.logger"
            ]
        },
        {
            "id": "cordova-plugin-console.console",
            "file": "plugins/cordova-plugin-console/www/console-via-logger.js",
            "pluginId": "cordova-plugin-console",
            "clobbers": [
                "console"
            ]
        },
        {
            "id": "cordova-plugin-device.device",
            "file": "plugins/cordova-plugin-device/www/device.js",
            "pluginId": "cordova-plugin-device",
            "clobbers": [
                "device"
            ]
        },
        {
            "id": "cordova-plugin-device.DeviceProxy",
            "file": "plugins/cordova-plugin-device/src/windows/DeviceProxy.js",
            "pluginId": "cordova-plugin-device",
            "merges": [
                ""
            ]
        },
        {
            "id": "cordova-plugin-splashscreen.SplashScreen",
            "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js",
            "pluginId": "cordova-plugin-splashscreen",
            "clobbers": [
                "navigator.splashscreen"
            ]
        },
        {
            "id": "cordova-plugin-splashscreen.SplashScreenProxy",
            "file": "plugins/cordova-plugin-splashscreen/www/windows/SplashScreenProxy.js",
            "pluginId": "cordova-plugin-splashscreen",
            "runs": true
        },
        {
            "id": "cordova-plugin-statusbar.statusbar",
            "file": "plugins/cordova-plugin-statusbar/www/statusbar.js",
            "pluginId": "cordova-plugin-statusbar",
            "clobbers": [
                "window.StatusBar"
            ]
        },
        {
            "id": "cordova-plugin-statusbar.StatusBarProxy",
            "file": "plugins/cordova-plugin-statusbar/src/windows/StatusBarProxy.js",
            "pluginId": "cordova-plugin-statusbar",
            "runs": true
        },
        {
            "id": "ionic-plugin-keyboard.KeyboardProxy",
            "file": "plugins/ionic-plugin-keyboard/src/windows/KeyboardProxy.js",
            "pluginId": "ionic-plugin-keyboard",
            "clobbers": [
                "cordova.plugins.Keyboard"
            ],
            "runs": true
        }
    ];
    module.exports.metadata = 
    // TOP OF METADATA
    {
        "cordova-plugin-console": "1.0.5",
        "cordova-plugin-device": "1.1.4",
        "cordova-plugin-splashscreen": "4.0.3",
        "cordova-plugin-statusbar": "2.2.2",
        "cordova-plugin-whitelist": "1.3.1",
        "ionic-plugin-keyboard": "2.2.1"
    };
    // BOTTOM OF METADATA
    });
cordova.define('cordova/plugin_list', function(require, exports, module) {
    module.exports = [];
    module.exports.metadata = 
    // TOP OF METADATA
    {
        "cordova-plugin-whitelist": "1.2.2"
    };
    // BOTTOM OF METADATA
    }); 
现在,我注意到
模块.exports.metadata中的每个插件在
模块.exports中也有一个条目,除了
cordova插件白名单

如果我为VS中创建的Corvoda应用程序打开相同的文件,我会看到以下内容

cordova.define('cordova/plugin_list', function(require, exports, module) {
    module.exports = [
        {
            "id": "cordova-plugin-console.logger",
            "file": "plugins/cordova-plugin-console/www/logger.js",
            "pluginId": "cordova-plugin-console",
            "clobbers": [
                "cordova.logger"
            ]
        },
        {
            "id": "cordova-plugin-console.console",
            "file": "plugins/cordova-plugin-console/www/console-via-logger.js",
            "pluginId": "cordova-plugin-console",
            "clobbers": [
                "console"
            ]
        },
        {
            "id": "cordova-plugin-device.device",
            "file": "plugins/cordova-plugin-device/www/device.js",
            "pluginId": "cordova-plugin-device",
            "clobbers": [
                "device"
            ]
        },
        {
            "id": "cordova-plugin-device.DeviceProxy",
            "file": "plugins/cordova-plugin-device/src/windows/DeviceProxy.js",
            "pluginId": "cordova-plugin-device",
            "merges": [
                ""
            ]
        },
        {
            "id": "cordova-plugin-splashscreen.SplashScreen",
            "file": "plugins/cordova-plugin-splashscreen/www/splashscreen.js",
            "pluginId": "cordova-plugin-splashscreen",
            "clobbers": [
                "navigator.splashscreen"
            ]
        },
        {
            "id": "cordova-plugin-splashscreen.SplashScreenProxy",
            "file": "plugins/cordova-plugin-splashscreen/www/windows/SplashScreenProxy.js",
            "pluginId": "cordova-plugin-splashscreen",
            "runs": true
        },
        {
            "id": "cordova-plugin-statusbar.statusbar",
            "file": "plugins/cordova-plugin-statusbar/www/statusbar.js",
            "pluginId": "cordova-plugin-statusbar",
            "clobbers": [
                "window.StatusBar"
            ]
        },
        {
            "id": "cordova-plugin-statusbar.StatusBarProxy",
            "file": "plugins/cordova-plugin-statusbar/src/windows/StatusBarProxy.js",
            "pluginId": "cordova-plugin-statusbar",
            "runs": true
        },
        {
            "id": "ionic-plugin-keyboard.KeyboardProxy",
            "file": "plugins/ionic-plugin-keyboard/src/windows/KeyboardProxy.js",
            "pluginId": "ionic-plugin-keyboard",
            "clobbers": [
                "cordova.plugins.Keyboard"
            ],
            "runs": true
        }
    ];
    module.exports.metadata = 
    // TOP OF METADATA
    {
        "cordova-plugin-console": "1.0.5",
        "cordova-plugin-device": "1.1.4",
        "cordova-plugin-splashscreen": "4.0.3",
        "cordova-plugin-statusbar": "2.2.2",
        "cordova-plugin-whitelist": "1.3.1",
        "ionic-plugin-keyboard": "2.2.1"
    };
    // BOTTOM OF METADATA
    });
cordova.define('cordova/plugin_list', function(require, exports, module) {
    module.exports = [];
    module.exports.metadata = 
    // TOP OF METADATA
    {
        "cordova-plugin-whitelist": "1.2.2"
    };
    // BOTTOM OF METADATA
    }); 
因此,白名单插件也没有其他功能


这里可能少了什么吗??这个白名单插件可能安装不正确吗?

我遇到过类似的情况,我的ajax调用在测试中运行良好,但当我转到PROD时,它们会失败

最终,我在试图访问的服务器上找到了一个丢失的中介证书。TEST有证书,PROD没有


我希望这能有所帮助。

过了很长一段时间,我做了很久以前应该做的事情,并在另一个网络上测试了该应用程序,它运行良好。从我家,或者如果设备连接到手机网络,没有问题。工作网络上只有问题。由于这有点不同,我为这个“新”问题创建了一个单独的解决方案,它可能与instrafructure有关,而不是app。谢谢。不知道你指的是哪个证书?我确信我的问题出在本地客户机上,因为请求似乎从未到达服务器(我甚至在Wireshark中都没有看到)。我的问题现在看起来可能是我正在测试的特定网络,所以我添加了这个来解决这个问题。我的ajax试图访问,运行someserver.net的机器有一个ssl证书,但是ssl证书链中的前一个证书丢失了。具体来说,是一个NetScaler实例丢失了中间证书。如果我没记错的话,当我们尝试Wireshark时,流量从未到达someserver.net,而是在NetScaler实例处停止。