Ajax请求接收html页面作为响应,网页上不会显示相同的响应:Codeigniter


Ajax request Receives html page as response and the same response is not shown on webpage : Codeigniter

我的代码接受注册号,在数据库中搜索该学生进行的所有交易,并返回到该学生支付的页面金额。问题是,即使我得到了对ajax的正确响应(使用chrome-dev工具检查),页面上也没有显示相同的响应。响应是一个完整的html页面

这是我的观点:

<div>
        <input type="text" class="regno" name="reg_no">
        <button class="search_student">Search</button>  
</div>
<table>
    <tr> 
     <?php if(!empty($transactions) and isset($transactions)): 
     foreach ($transactions as $key => $row) { ?>
        <td> <?php echo $row->amount_paid; ?> </td>
     <?php } endif;
      ?>
    </tr>
</table>

这里是js函数:

$('.search_student').click(function(){
    //e.preventDefault();
    var regno=$(".regno").val();
    //window.alert(regno);
    $.ajax({
        type : "POST",
        url : "students/get_details",
        data : { 'reg_no' : regno }
    }).done(function(){
            //window.alert("Success");
            //location.reload();
    }).fail(function(){
         window.alert("Could not send data to Server.");
    });
});

这是我的控制器:

public function get_details()
    {
        $roll = $this->input->post('reg_no');              
        $data['transactions'] = $this->student_model->get_student_transactions($roll);
        $data['scripts'] = array ('../bootstrap.min.js','../buttons.js');
        $this->_render_page('allotment', $data);
        //$this->details();
        //var_dump($data['transactions']);
    }

这个模型运行良好,经过反复试验。支付的金额显示在ajax响应中(附截图),但网页上没有显示。提前感谢!!回复截图:http://www.4shared.com/download/twAiI9Odce/upload.jpg?lgfp=3000

更改控制器

public function get_details() {
        $roll = $this->input->post('reg_no');
        $data['transactions'] = $this->student_model->get_student_transactions($roll);
        // $data['scripts'] = array ('../bootstrap.min.js','../buttons.js');
        $this->_render_page('allotment', $data);
    }

查看

<table>
    <tr> 
     <?php if(!empty($transactions) and isset($transactions)): 
     foreach ($transactions as $key => $row) { ?>
        <td> <?php echo $row->amount_paid; ?> </td>
     <?php } endif;
      ?>
    </tr>
</table>

AJAX

$('.search_student').click(function () {
        //e.preventDefault();
        var regno = $(".regno").val();
        //window.alert(regno);
        $.ajax({
            type: "POST",
            url: "students/get_details",
            data: {'reg_no': regno}
        }).done(function (data) {
            $('table').html(data)
        }).fail(function () {
            window.alert("Could not send data to Server.");
        });
    });