[eluser]eoinmcg[/eluser]
firstly, refactor your code and embrace MVC.
i'd move the building of the file list to a model.
in your controller you'll then get the files from the model and send it to a view.
Code:
//in your controller
$dir = 'path/to/dir';
$data['files'] = $this->model_name->build_file_list($dir);
$this->load->view('viewname.php', $data);
//in your view: viewname.php
<div id="ajax_wrap">
<div id="ajax_using">
<?php foreach ($files as $file): ?>
<a href="<?php echo "><?php echo $file; ?></a>
<?php endforeach; ?>
</div>
</div>
now that things are not such a mess, a splash of jquery would be the easiest way to update
Code:
update();
function update() {
$.ajax({
type: 'POST',
url: '/controller/method',
timeout: 2000,
success: function(data) {
$("#ajax_wrap").html(data);
window.setTimeout(update, 20000);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
// deal with possible errors
window.setTimeout(update, 20000);
}
});
}