How To Reload/Refresh A Page Using Javascript Together With Jquery

JavaScript provides several ways to reload or refresh an HTML page merely the touchstone way to practise this task is yesteryear using window.location object. This object provides a reload() method which instructs the browser to reload the page. The browser tin practise it from its cache or from the server, which depends upon optional parameter i.e. reload(true) volition reload the page from the server merely reload(false) volition solely reload the page from browser's cache, which may or may non stand upward for the electrical flow version at the server.


You tin combine both jQuery too JavaScript to wrap the page refresh code every bit shown inwards our example. Btw, this is non the solely way to refresh a page inwards JavaScript, you lot tin besides utilisation history.go(0) too location.replcace(locatoin.pathname) to reload the page.


JavaScript too jQuery event to reload a page 

In this example, I volition say you lot how to reload a page from both server too browser's cache using jQuery too JavaScript. In our HTML nosotros accept 2 buttons, 1 for reloading page from the server too other from refresh page from browser's cache. Though location.reload() volition piece of employment inwards all browser, you lot tin besides utilisation jQuery to wrap other code e.g. attaching a click handler to the 2 buttons.


Here is the sum event for your reference:

<html> <head> <title>How to reload/refresh a page using jQuery</title> </head>  <body>  <h2>Reloading a page using jQuery too 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> $(document).ready(function() {  $("#btn_refresh").click(function(){ location.reload(false); //loads from browser's cache   });  $("#btn_reload").click(function(){ location.reload(true); //loads from server  });  }); </script>  </body> </html> 



That's all nearly how to reload or refresh a page inwards jQuery using JavaScript. Just think that window.location.reload() volition learn the browser to reload the page, which way downloading information from the server, parsing, too displaying it. You tin besides reload a page from browser's cache yesteryear using the location.reload(false) method. You tin read to a greater extent than nearly jQuery methods on jQuery inwards Action book, 1 of the best resources to larn too utilisation jQuery inwards existent globe projects.

Other jQuery articles for you
  • 5 Books to larn jQuery for Web developers (books)
  • How to acquire electrical flow URL, Parameters, too Hash using jQuery? (solution)
  • jQuery Hello World Example (program)
  • How to utilisation to a greater extent than than 1 jQuery UI DatePicker inwards JSP page? (example)
  • How to practise tab-based UI using jQuery? (example)
  • How to alter to a greater extent than than 1 chemical gene inwards 1 line? (example)
  • How to redirect a page URL using jQuery too JavaScript? (solution)
  • How to write HelloWorld inwards jQuery? (solution)
  • 20 jQuery Interview Questions for Java Web Developers (list)
  • How to charge jQuery inwards a spider web page? (solution)



Further Reading
The Complete jQuery Course: From Beginner To Advanced!
Up too Running amongst jQuery
jQuery Fundamentals By Dan Wahlin

Thanks for reading this article. If you lot similar this tutorial too hence delight portion amongst your friends too colleagues. If you lot accept whatever query or feedback too hence delight drib a comment. 

Belum ada Komentar untuk "How To Reload/Refresh A Page Using Javascript Together With Jquery"

Posting Komentar

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel