我在加載到我的頁面上的div中有幾個視圖。
和我有類似的東西:
<div id=header>
...
...
</div>
<div id=content>
...
...
...
<a href="#" class="ref"> refresh extra div </a>
<div id=extra>
<?php $this->load->view('extra.php'); ?>
</div>
....
...
...
</div>
<div id=footer>
...
...
</div>
現在我想一些動作之後刷新我的#extra格,例如點擊「刷新額外的div」鏈接。
I was trying to use jquery in a way:
$(".ref").click(function() {
$('#extra').load(<?php $this->load->view('extra.php'); ?>);
});
但它不工作 - 如何做到這一點?如何動態刷新視圖加載到他們的意見?
謝謝!
@@更新
我有相當長的extra.php視圖文件,並jquery.html()得到它,只有當所有的文件是在一個線(讀取)是一種方法,使jQuery的.html()獲取整個文件的形式?
它加載:
<table><tr></tr><tr></tr><tr></tr></table>
但doesnt't加載此:
<table>
<tr>....</tr>
<tr>....</tr>
<tr>....</tr>
</table>
它不工作對我來說,我的extra.php文件在默認情況下笨的視圖目錄... – pawel
你試過'$(「#額外」)。HTML(」 負載>視圖(」 extra.php');?>「);' – Rab
它的工作原理!謝謝! :) – pawel