Monday 30 December 2019

How to refresh a page with jQuery

How to refresh a page with jQuery

Use the JavaScript location.reload() Method

You can simply use the JavaScript location.reload() method to refresh or reloads the page. This method optionally accepts a Boolean parameter true or false.

If the parameter true is specified, it causes the page to always be reloaded from the server. But, if it is false (which is default) or not specified, the browser may reload the page from its cache.

Let's check out an example to understand how this method basically works:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Reload the Page Using jQuery</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
    $(document).ready(function(){
        $("button").click(function(){
            location.reload(true);
        });
    });
</script>
</head>
<body>
    <button type="button">Reload page</button> 
</body>
</html>

No comments:

Post a Comment



Asp.net tutorials