コントローラークラスで
function get_view_ajax()
{
$data['username] = $_POST['username];
$response = $this->load->view('radius/radius_corporate_graph',$data,TRUE);
echo $response;
}
ajax 呼び出しを開始するビュー ファイル内
$('#button').click(function(){
var username = $('#username').val();
$.ajax({
type:'POST',
url:"<?php echo base_url(); ?>controller_name/get_view_ajax/",
data: "username="+username,
success:function(msg){
$("#div_result").html(msg);
},
error: function(result)
{
$("#div_result").html("Error");
},
fail:(function(status) {
$("#div_result").html("Fail");
}),
beforeSend:function(d){
$('#div_result').html("<center><strong style='color:red'>Please Wait...<br><img height='25' width='120' src='<?php echo base_url();?>img/ajax-loader.gif' /></strong></center>");
}
});
});
<div id="div_result">
<a href="#" id="button">Click here </a>
get_view_ajax 関数で参照されるコントローラー関数 (extra_info.php) に読み込まれる別のビュー ファイル
<h1>This page is called from ajax function </h1>