Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
phonegap android ajax over ssl失败_Android_Jquery_Cordova_Ssl_Jquery Mobile - Fatal编程技术网

phonegap android ajax over ssl失败

phonegap android ajax over ssl失败,android,jquery,cordova,ssl,jquery-mobile,Android,Jquery,Cordova,Ssl,Jquery Mobile,我用Phonegap和Jquery Mobile开发了一个应用程序。出于某些原因,我还需要从https域获取数据。在IOS上,一切都很完美,但在Android上,我总是会遇到以下错误,请求失败 06-17 17:16:33.890 6079-6154/de.sistecs.einlass E/chromium_net: external/chromium/net/socket/ssl_client_socket_openssl.cc:905: [0617/171633:ERROR:ssl_cl

我用Phonegap和Jquery Mobile开发了一个应用程序。出于某些原因,我还需要从https域获取数据。在IOS上,一切都很完美,但在Android上,我总是会遇到以下错误,请求失败

06-17 17:16:33.890 6079-6154/de.sistecs.einlass E/chromium_net: external/chromium/net/socket/ssl_client_socket_openssl.cc:905: 
[0617/171633:ERROR:ssl_client_socket_openssl.cc(905)] handshake failed; returned -1, SSL error code 1, net_error -107
下面是一个简单的示例代码

$(document).on("pageinit", function (event, ui) {
    $("#test").click(function () {
        $.ajax({
            type: "POST",
            url: "https://test.sistecs.de/sismedia/test.php",
            success: function (response) {
                $("#testmsg").text(response);
            }
        });
    });
});
我读过数百篇帖子,但没有找到解决问题的办法。 服务器的证书是有效的


有人能帮我吗?

这似乎是一个跨来源的问题

使用jQuery Mobile,您应该将$.Mobile.allowCrossDomainPages$.support.cors设置为true

<script>
    $( document ).on( "mobileinit", function() {
        $.mobile.allowCrossDomainPages = true;
        $.support.cors = true;
    });
</script>

$(文档).on(“mobileinit”,函数(){
$.mobile.allowCrossDomainPages=true;
$.support.cors=true;
});
还要确保您的PHP页面相应地设置了标题。例如:

<?php
    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Methods: GET,PUT,POST,DELETE');
    header('Access-Control-Allow-Headers: Content-Type');
    echo "test";
?>

编辑:我没有测试代码,这就是一个例子。根据需要进行调整

   var myJson = {
        'Par1': 'par'
    };

    $.ajax({
        url: baseUrlAjaxServices + "/....",
        data: JSON.stringify(myJson),

        method: "POST",
        crossDomain: true,
        dataType: 'json',
        contentType: 'application/json',
    })
  .done(function (data) {
     //...
  }).fail(function (error) {
      console.log(error);
  });