Reputation: 6156
I have a few views in divs loaded on my page.
and I have something like that:
<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>
Now I want to refresh my #extra div after some action, for example clicking on the “refresh extra div” link.
I was trying to use jquery in a way:
$(".ref").click(function() {
$('#extra').load(<?php $this->load->view('extra.php'); ?>);
});
but it doesnt work - how to do it? How to dynamically refresh divs with views loaded into them?
Thanks!
@@update
I have quite long extra.php view file, and jquery.html() gets it only when all file is in the one line (unreadable) is it a way to make jquery.html() to get the whole file on it's form?
It loads:
<table><tr></tr><tr></tr><tr></tr></table>
but it doesnt't load this:
<table>
<tr>....</tr>
<tr>....</tr>
<tr>....</tr>
</table>
Upvotes: 1
Views: 16729
Reputation: 14747
And how about passing a "true" as second parameter in order to return the view markup?
$('#extra').html("<?php $this->load->view('extra.php', TRUE); ?>");
Upvotes: 0
Reputation: 35582
you just need to try this
$('#extra').load('extra.php');
instead of $('#extra').html("<?php $this->load->view('extra.php'); ?>");
Upvotes: 4