【问题标题】:Cordova Ajax request [closed]科尔多瓦阿贾克斯请求[关闭]
【发布时间】:2020-10-22 01:50:59
【问题描述】:

你好,我在 Apache cordova 9.0.0 中使用 ajax 请求到 php codeigniter,everythink 可以在浏览器上工作,但是当我用 cordova 模拟时它不起作用。 Cordova 中的代码:

$.ajax({
            method: 'get',
            url: baseUrl + 'Cartography/Boutique/' + it,
            dataType: 'json',
            success: function(data) {
                var code = '';
                for (var i = 0; i < data.length; i++) {
                    traitement...;
                }
                $("#listeBoutique").html(code);
                $('.boutique').DataTable();
            },
            error: function() {
                alert('Impossible de charger les données');
            }
        });

我在 Codeigniter 中的代码

public function Boutique($it)
{
    $this->load->model('Boutique_model', 'boutique');
    $data =$this->boutique->get_Boutique_Itineraire($it);
    echo json_encode($data);
}

php文件头

header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: GET, OPTIONS");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); 
header("Content-Type: application/json");

【问题讨论】:

标签: php ajax codeigniter cordova cross-domain


【解决方案1】:

解决了!!! 只需在 Android 设备上安装最新版本的 WebView

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-19
    • 2010-10-11
    • 1970-01-01
    • 1970-01-01
    • 2018-05-15
    • 2018-07-04
    • 1970-01-01
    • 2023-03-21
    相关资源
    最近更新 更多