CodeIgniter - 查看页面未加载但在控制台上运行 returns 响应

CodeIgniter - View page is not loading but function returns response on console

我正在尝试处理服务器 response.I 通过 ajax 将此响应解析到我的控制器。从控制台,我从 POST getInternalRouteServerResponse 得到正确的结果,但未加载 VIEW 页面。有什么想法吗?

这是我的控制器:

public function getInternalRouteServerResponse()
{
    $response = $this->input->post();

        $html = $this->load->view("front/curse_interne.php", array(
            'response' => $response
        ), true);
        echo json_encode(array("status" => 1, "html" => $html));
}

这是我的观点 (curse_interne.php):

<?php var_dump($response); exit();?>

我是否正确加载了我的视图? 提前致谢!

更新:在此处添加了 ajax 代码:

$.ajax({ //hande the first response
    url: MyVariable.urlsite + "curse_interne/searchInternalRoute",
    type: "POST",
    dataType: 'json',
    data:
    '&departure=' + $("#internal_origin_station option:selected").val()
    + '&arrival=' + $("#internal_destination_station option:selected").val()
    + '&date=' +  $("#datepicker_plecare").val()
    + '&category=' + categories
    + '&clear_session=1',

    beforeSend: function () {
        $('html, body').animate({scrollTop: $('#right-content-mainwrapper').position().top}, 'slow');
        $("#right-content-mainwrapper").html("<div style='font-size: 18px;margin-bottom: 25px;margin-top: 25px;text-align: center;'>Va rugam asteptati. Calculam rutele interne.</div> \n\
                    <div  style='text-align:center;'><img src='" + base_url + "assets/images/loader-big.gif' style='display: inline-block;vertical-align: middle;margin-left:10px;'/></div>\n\
         ");
    },
    success: function (response) {
        if (response.status == '1') {

            $.ajax({ // here is the response that I want to show in view
                url: MyVariable.urlsite + "curse_interne/getInternalRouteServerResponse",
                type: "POST",
                dataType: 'json',
                data: response

            })



        } else {
            $("#right-content-mainwrapper").html("<div id='right-content-mainwrapper'>\n\
                        <div id='comanda-bilet-maincontent'><div class='error'>" + response.message + "</div></div></div>");
        }
    }

})

需要更正您的第二次 ajax 电话。您错过了 success。并在成功后添加以下行,如

$("#right-content-mainwrapper").html(data.html);

所以,

$.ajax({ // here is the response that I want to show in view
    url: MyVariable.urlsite + "curse_interne/getInternalRouteServerResponse",
    type: "POST",
    dataType: 'json',
    data: response,
    success: function (data) {
        //console.log(data.html);
        $("#right-content-mainwrapper").html(data.html);
    }
})