私はいくつかのテーブルを持ち、数秒ごとにそれ自身を更新するホームページを持っていました。以下codeigniterエラーでjqueryを使用してページコンテンツを読み込む
は、ビューファイル(inside_view.php)
<script>
$(document).ready(function() {
$("#encontainer").load("inside/home_en");
var refreshId = setInterval(function() {
$("#encontainer").load('inside/home_en?randval='+ Math.random());
}, 9000);
$.ajaxSetup({ cache: false });
});
</script>
<div id="encontainer"></div>
、ここでjQueryのためのコードは、ここでコントローラコード(inside.php)
function index(){
// Write to $title
$this->template->write('title', 'Update to date data');
$this->template->write_view('header', 'header_content', true);
// Write to $content
$this->template->write_view('content', 'inside_view', true);
// Write to $sidebar
$this->template->write_view('sidebar', 'user_side_menu');
// Load and display the template
$this->template->load();
}
function home_en(){
//look latest enquirer data
$data['enresults'] = $this->customer_model->get_cp_list(5);
$this->load->view('ajax_home_en',$data);
}
は(ajax_home_enです。私はこのURLを使ってこのページを表示しようとすると、PHP)コード
<link type="text/css" rel="stylesheet" href="http://bravonet.my/tombocrm/assets/css/table.css" />
<?php if($enresults->num_rows() == 0){
echo 'No data result, please insert one';
}else{
?>
<table width="100%">
<tr>
<th>CP code</th>
<th>Code</th>
<th>Name</th>
</tr>
<?php foreach($enresults->result() as $row){
echo '<tr class="tr'. alternator('1', '2'). '">';
?>
<td align="center"><?php echo $row->cp_code?></td>
<td align="center"><?php echo $row->en_code?></td>
<td align="center"><?php echo $row->name?></td>
<td align="center"><?php echo anchor('customers/patient_update_view/'.$row->eid,'Edit');?></td>
<td align="center"><?php echo anchor('customers/cp_details_view/'.$row->cpid,'View');?></td>
</tr>
<?php }?>
</table>
<?php
echo anchor('customers','View all data');
} ?>
すべてが大丈夫です http://mysite.com/inside
が、私は http://mysite.com/inside/またはこのhttp://mysite.com/inside/index
<div id="encontainer"></div>
このURLを入力し1回)(内部の代わりにhome_en()ビューの図を示します。 nはボックス内で連続的なページリフレッシュを行います(IEが応答を停止するようにします)。
URLに「/」や/インデックスを追加するとこのようなバグが発生するのはなぜか分かりませんが、JavaScriptのエラーが表示されますか?
進んだ!
THXのDUDE! $( "#encontainer")。load( "/ inside/home_en"); $( "#encontainer")。load( '/ inside/home_en?randval =' + Math.random()); は機能しませんが、スラッシュを<?php base_url()?>に変更するとすべてがうまくいきます。 –