hi all,
i am having a php page where we can upload and download files.Those files which are uploaded will be displayed in a table on the same page,for that i need to refresh page.So i used

<meta http-equiv="refresh"  content="3">

but it is refreshing for every 3 seconds. That causes some problem for me because when the user want to upload a file he clicks on browse and select some file if this happens in 3 seconds that is ok,but if it takes more than that,even if he selects the file due to that refresh he cannot upload.so for that i need to refresh only some part of my page. I came to know that ajax can do that. so can any one...
Thanks in advance.

Using jQuery javascript library:

<?php
// filename: files.php

$files = get_uploaded_files();
$i = 1;
foreach ($files as $f) {
    echo "$i) $f<br>";
    $i++;
}
?>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
function getfiles() {
    var url = "files.php?t=" + (new Date()).getTime(); //kill browser cache
    // send request and load results into element with id=filelist
    jQuery("#filelist").load(url);
}

jQuery(function() {
    // Call getfiles function every 3 seconds.
    setInterval(getfiles, 3000);
});
</script>
</head>
<body>
Here are the files (updated every 3 seconds):
<div id="filelist"></div>
</body>
</html>

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.