Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using jQuery to reload entire page

Tags:

jquery

Can I use jQuery.load() or and other jQuery function to load the entire page?

Edit: I am looking for the ability to include data that the jQuery functions offer.

like image 673
Brian Avatar asked Mar 03 '10 04:03

Brian


People also ask

How can I refresh a page with jquery?

Method 1: Using the location. reload(): The location. reload() method reloads the current web page emulating the clicking of the refresh button on the browser.

How do you refresh a page after Ajax success?

The location. reload() method, will reload (or refresh) an entire web page after the Ajax has performed its operation, that is, extracted data from an xml file. Therefore, I have added location. reload() inside the success callback function.


4 Answers

You don't need jQuery for that. Just do:

window.location.reload();
like image 182
Ross Snyder Avatar answered Oct 21 '22 05:10

Ross Snyder


As you would like to have the information in a new page (the old being totaly replaced by new content IS a new page), ajax is not the answer, because it is used to place new content in an old page.

i would recommend injecting a form into the current page using javascript and submitting this form programmatically.

Quick'n'dirty (untested):

$("#formsPlaceholder").append('<form action="newpage" method="post" id="newForm"><input type="textfield" name="foo" value="bar"/></form>');
$("#newForm").submit();
like image 23
Phil Rykoff Avatar answered Oct 21 '22 05:10

Phil Rykoff


No need for jQuery. location.reload(); will do it.

like image 29
Amber Avatar answered Oct 21 '22 04:10

Amber


Do you want to refresh the page, or load the contents of a file into the page? To refresh the page you can call window.history.go(). To load another page into the body of this page, you can call $("body").load("path/to/other/page.html"). The other html page should not include the html, head or body tags, just the content of the body.

like image 25
Marius Avatar answered Oct 21 '22 03:10

Marius