tags:

views:

64

answers:

5

Can anyone tell the jquery code for automatic refreshing of a page.

+2  A: 

I've always used

window.location = window.location

But it turns out that

window.location.reload()

exists, and it also more semantically correct.

Of course, this is not jQuery. Remember jQuery is a framework built on top of the JavaScript language.

If you wanted to do it after a certain time, wrap it with setTimeout().

window.setTimeout(function() {

    window.location = window.location

}, 1500);
alex
Why did you complete your answer with info from an answer for this same question. This does not seem fair to me, you know. Especially that you had no idea about feature.
Ionuț G. Stan
@Ionut I voted the answer up and decided to edit it in just to be more *complete* with my own answer. He still has the most upvotes. I thought by including a link to my source and voting him up, I had *paid my dues* to the help he gave me.
alex
+4  A: 
window.location.reload()

No jQuery needed for this.

Ionut Staicu
Oh wow, didn't know that existed. +1
alex
A: 

i am using something like this -

    jQuery(".form_" + form_count).html("<div id='message'></div>")
    jQuery('#message').html("<center><h2><br><br>Thank You Your form has been submitted.</h2></center>")
window.setTimeout(function() {
    history.go(-1);
}, 1950);

Now what i want is that after the browser has moved one page back to history that page should be refreshed . I tried using the above answers but no help.

ayush
A: 

Hi. Refer this link which is helpful for you http://www.brightcherry.co.uk/scribbles/2009/02/26/jquery-auto-refresh-div-every-x-seconds/

Sonal Patil
A: 

window.location.reload() is equivalent to pressing the reload button in your browser. window.location = window.location is equivalent to pressing enter in the address bar.

When you call window.location.reload(), all other resources are also revalidated. This means the cache fresness for all stylesheets, scripts and images is checked by performing extra HTTP-requests. At least in Firefox this behavior exists, I don't know how other browsers behave.

Robert Ros