Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a message before auto refresh div using jquery

Tags:

html

jquery

css

php

I am trying to display a message before an auto refresh div. I have created this code for the auto refresh.

$(document).ready(function()
{
 if setInterval(function() {
   $("#pagere").load(location.href + " #pagere");}, 10000);             
 });

I also need to display a message like "page auto refresh in 3 sec...". How can I do that?

like image 919
user564 Avatar asked Aug 19 '15 08:08

user564


3 Answers

Try this :)

$(document).ready(function()
    {
      var alertTimeSec = 3000; //alert time in ms
      var delayTimeSec = 10000; //time delay to refresh in ms
            setTimeout(function () {
               alert("3 Sec more")
            }, (delayTimeSec-alertTimeSec));
            setInterval(function() {
            $("#pagere").load(location.href + " #pagere");}, delayTimeSec);    
    });
like image 85
Nofi Avatar answered Nov 01 '22 07:11

Nofi


<script>
    setInterval(function()
    {
        $("#pagere_container").load(location.href + " #pagere");
    }, 3000);
</script>

<div id="pagere_container">
    <div id="pagere">
        page auto refresh in 3 sec...
    </div>
</div>
like image 34
Edwin Thomas Avatar answered Nov 01 '22 07:11

Edwin Thomas


setTimeout(function() {
   $('#load_status').show();
}, 5000);
$("#pagere").load(location.href + " #pagere");}, 10000);

-this will give you 5 sec of timeout before refresh

like image 2
Domain Avatar answered Nov 01 '22 07:11

Domain