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

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


You tin combine both jQuery in addition to JavaScript to wrap the page refresh code equally shown inwards our example. Btw, this is non the exclusively way to refresh a page inwards JavaScript, you lot tin equally good utilization history.go(0) in addition to location.replcace(locatoin.pathname) to reload the page.


JavaScript in addition to jQuery instance to reload a page 

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


Here is the sum instance for your reference:

<html> <head> <title>How to reload/refresh a page using jQuery</title> </head>  <body>  <h2>Reloading a page using jQuery in addition to 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 virtually how to reload or refresh a page inwards jQuery using JavaScript. Just recollect that window.location.reload() volition learn the browser to reload the page, which way downloading information from the server, parsing, in addition to displaying it. You tin equally good reload a page from browser's cache past times using the location.reload(false) method. You tin read to a greater extent than virtually jQuery methods on jQuery inwards Action book, i of the best resources to larn in addition to utilization jQuery inwards existent basis projects.

Other jQuery articles for you
  • 5 Books to larn jQuery for Web developers (books)
  • How to acquire electrical flow URL, Parameters, in addition to Hash using jQuery? (solution)
  • jQuery Hello World Example (program)
  • How to utilization to a greater extent than than i jQuery UI DatePicker inwards JSP page? (example)
  • How to exercise tab-based UI using jQuery? (example)
  • How to alter to a greater extent than than i chemical ingredient inwards i line? (example)
  • How to redirect a page URL using jQuery in addition to 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 in addition to Running alongside jQuery
jQuery Fundamentals By Dan Wahlin

Thanks for reading this article. If you lot similar this tutorial in addition to hence delight part alongside your friends in addition to colleagues. If you lot accept whatsoever query or feedback in addition to hence delight drib a comment. 

0 Response to "How To Reload/Refresh A Page Using Javascript Together With Jquery"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel