Motyar

@motyar

Freelance Web Developer

Static Web Hosting, made easy

Aug 3, 2017

Refresh element without page refresh.

Here is the code ( using jQuery) to refresh a div contents without page refresh.

setInterval(function(){ 
    $('#divId').load('?_=' + (new Date()).getTime()+' #divId');
},5000);
You can add this simple animation to make it more effective

setInterval(function(){                         
        $('#divId').fadeOut('fast', function() {       
            $('#divId').load('?_=' + (new Date()).getTime()+' #divId',function() {
                                $(this).fadeIn('fast');                                                                                        
            });                                     
        });                                         
    },5000);  

Labels: ,




By :