0

if you see below code "left-profile-load.php" will load every 9 seconds but the problem is i need to wait 9 second also for initial load.

So how to avoid this problem(initial load) ?

<script>
var auto_refresh = setInterval(
function()
{
$.ajaxSetup({ cache: false });
$('#preview_project').fadeOut("slow").load('left-profile-load.php').fadeIn("slow");
}, 9000);
</script>

2 Answers 2

2

You could define a function:

$.ajaxSetup({ cache: false });
var load = function() {
    $('#preview_project').fadeOut("slow").load('left-profile-load.php').fadeIn("slow");    
};

and then:

var auto_refresh = window.setInterval(load, 9000);
load();

or simply use setTimeout with an anonymous function:

(function() {
    $('#preview_project').fadeOut('slow').load('left-profile-load.php').fadeIn('slow');
    window.setTimeout(arguments.callee, 9000);
})();

Notice how arguments.callee is used here to obtain a reference to the containing anonymous function in order to achieve a recursive calls.

0
1

load the left-profile-load.php when the document ready at first

$(function(){
      $('#preview_project').fadeOut("slow").load('left-profile-load.php').fadeIn("slow")
})
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.