1
I have this function:
if ($files_count == 0) {
?>
<img src="img/upload.gif">
<?php
}
And I needed this to update every five seconds refresh on the page. I have tested several AJAX functions and I can’t. How to solve this?
1
I have this function:
if ($files_count == 0) {
?>
<img src="img/upload.gif">
<?php
}
And I needed this to update every five seconds refresh on the page. I have tested several AJAX functions and I can’t. How to solve this?
1
Hiccup!
HTML:
<div class="container"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
SCRIPT:
setInterval(function () {
check_files();
}, 5000);
function check_files() {
$.ajax({
url: 'path/to/php/file.php',
type: 'GET',
cache: false,
data: {},
success: function (resp) {
if (resp == 0) {
$('.container').html('<img src="img/upload.gif" />');
} else {
/// mais alguma coisa
}
}
});
}
Can you explain how this code solved your problem? So it is useful for others who may have the same problem in the future
And by the way, I think sending AJAX orders with timer can be a problem. It was best to make a new request with setTimeout shot from within the success
or at least there is a flag there that the setibterval
vefiric.
Browser other questions tagged php javascript ajax
You are not signed in. Login or sign up in order to post.
Hmmm... much information is missing here to be able to answer this question... What is the
$files_count
?, can explain better what you want to do?– Sergio
Hello, I already solved the problem. files_count is a variable with information from a mysql table. I will post the solution
– user3465632