How to Reload,Refresh Page through Jquery, Javascript

How do you reload,refresh a page through Jquery, Javascript code. Having trouble finding the answer, this tutorial is for you.

How to Reload,Refresh Page through Jquery, Javascript

To reload a page with jquery use location.reload() method. By default location.reload() refresh the page from cache.

Syntax –

If you want your browser to reload the page from server instead of cache then true forceget parameter which is false by default.

Difference between window.onload and document.ready.

Let’s check some example –

Subscribe Our Tutorials

Get Latest Updates on Facebook

Refresh, Reload page on the click of button

Create one button with id click.

One the click of button, reload or refresh the page.

What the above code does ?

We select the button by id using jquery selector. And then we check click event on button, when someone clicks on button then our code refresh or reload the page.

Alternative Methods to Reload, Refresh the Page

Using window.location.reload() and history.go(0) method.

go method loads specific page from history list. So if i write history.go(-1) it loads one page backward.

To load current page we use history.go(0) . 0 is passed for current page.

About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.
Tagged , . Bookmark the permalink.