How To Reload/Refresh A Page Using Javascript Too Jquery

JavaScript provides several ways to reload or refresh an HTML page simply the criterion way to practise 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 give the sack 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 simply reload(false) volition entirely reload the page from browser's cache, which may or may non correspond the electrical flow version at the server.


You tin give the sack combine both jQuery together with JavaScript to wrap the page refresh code equally shown inwards our example. Btw, this is non the entirely way to refresh a page inwards JavaScript, y'all tin give the sack likewise utilization history.go(0) together with location.replcace(locatoin.pathname) to reload the page.


JavaScript together with jQuery event to reload a page 

In this example, I volition say y'all how to reload a page from both server together with browser's cache using jQuery together with JavaScript. In our HTML nosotros convey ii buttons, i for reloading page from the server together with other from refresh page from browser's cache. Though location.reload() volition piece of job inwards all browser, y'all tin give the sack likewise utilization jQuery to wrap other code e.g. attaching a click handler to the ii buttons.


Here is the amount event for your reference:

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

Other jQuery articles for you
  • 5 Books to larn jQuery for Web developers (books)
  • How to acquire electrical flow URL, Parameters, together with 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 practise tab-based UI using jQuery? (example)
  • How to alteration to a greater extent than than i chemical cistron inwards i line? (example)
  • How to redirect a page URL using jQuery together with 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 together with Running amongst jQuery
jQuery Fundamentals By Dan Wahlin

Thanks for reading this article. If y'all similar this tutorial together with therefore delight portion amongst your friends together with colleagues. If y'all convey whatever enquiry or feedback together with therefore delight driblet a comment. 

Sumber https://javarevisited.blogspot.com/

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

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel