javascript - Comment puis-je rafraîchir une page avec jQuery

Mots clés : javascriptjqueryrefreshreloadjavascriptjavascriptjavascript

meilleur 4 Réponses javascript - Comment puis-je rafraîchir une page avec jQuery

vote vote

97

$('#something').click(function() {     location.reload(); }); 
vote vote

87

var methods = [    "location.reload()",    "history.go(0)",    "location.href = location.href",    "location.href = location.pathname",    "location.replace(location.pathname)",    "location.reload(false)"  ];    var $body = $("body");  for (var i = 0; i < methods.length; ++i) {    (function(cMethod) {      $body.append($("<button>", {        text: cMethod      }).on("click", function() {        eval(cMethod); // don't blame me for using eval      }));    })(methods[i]);  }
button {    background: #2ecc71;    border: 0;    color: white;    font-weight: bold;    font-family: "Monaco", monospace;    padding: 10px;    border-radius: 4px;    cursor: pointer;    transition: background-color 0.5s ease;    margin: 2px;  }  button:hover {    background: #27ae60;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
vote vote

77

location.reload(); 
vote vote

68

$.ajax({     url: "",     context: document.body,     success: function(s,x){         $(this).html(s);     } }); 

Questions similaires