You possibly can mix each jQuery and JavaScript to wrap the web page refresh code as proven in our instance. Btw, this isn’t the one option to refresh a web page in JavaScript, you may as well use historical past.go(0) and location.replcace(locatoin.pathname) to reload the web page.
JavaScript and jQuery instance to reload a web page
On this instance, I’ll inform you how you can reload a web page from each the server and browser’s cache utilizing jQuery and JavaScript. In our HTML we’ve two buttons, one for reloading pages from the server and the opposite for the refresh web page from the browser’s cache.
Right here is the total instance to your reference:
<html> <head> <title>The way to reload/refresh a web page utilizing jQuery</title> </head> <physique> <h2>Reloading a web page utilizing jQuery and JavaScript</h2> <button id="btn_reload">Reload from Server</button> <button id="btn_refresh">Reload from Browser's cache</button> <script src="//code.jquery.com/jquery-1.6.2.min.js"></script> <script> $(doc).prepared(operate() { $("#btn_refresh").click on(operate(){ location.reload(false); //masses from browser's cache }); $("#btn_reload").click on(operate(){ location.reload(true); //masses from server }); }); </script> </physique> </html>
That is all about how you can reload or refresh a web page in jQuery utilizing JavaScript. Simply do not forget that window.location.reload() will instruct the browser to reload the web page, which suggests downloading knowledge from the server, parsing, and displaying it.
Different jQuery articles for you
- 5 Books to be taught jQuery for Internet builders (books)
- The way to get the present URL, Parameters, and Hash utilizing jQuery? (answer)
- The way to modify a number of components in a single go? (jquery tutorial)
- The way to discover all unchecked checkbox in jQuery? (tutorial)
- jQuery Hiya World Instance (program)
- The way to use a couple of jQuery UI DatePicker on the JSP web page? (instance)
- The way to create tab-based UI utilizing jQuery? (instance)
- The way to use a couple of jQuery UI DatePicker on the JSP web page? (instance)
- The way to examine/uncheck checkboxes in jQuery? (tutorial)
- The way to redirect a web page URL utilizing jQuery and JavaScript? (answer)
- 20 jQuery Interview Questions for Java Internet Builders (listing)
- The way to load jQuery on an online web page? (answer)
Thanks for studying this text. In the event you like this tutorial then please share it with your folks and colleagues. If in case you have any questions or suggestions then please drop a remark.