jQuery로 페이지를 새로 고치는 방법은 무엇입니까?
질문
jQuery로 페이지를 새로 고치는 방법은 무엇입니까?
답변
location.reload ()를 사용하십시오.
$('#something').click(function() {
location.reload();
});
reload () 함수는 캐시가 아닌 서버에서 다시로드를 강제하도록 true로 설정할 수있는 선택적 매개 변수를 취합니다.매개 변수 기본값은 기본적으로 기본적으로 페이지에서 브라우저의 캐시에서 다시로드 될 수 있습니다.
답변
JavaScript로 페이지를 새로 고치는 무제한 방법이 여러 있습니다.
location.reload()
history.go(0)
location.href = location.href
location.href = location.pathname
location.replace(location.pathname)
location.reload(false)
If we needed to pull the document from the web-server again (such as where the document contents change dynamically) we would pass the argument as
true
.
목록을 창의적으로 계속할 수 있습니다.
window.location = window.location.location. window.self.window.self.window.window.location = window.location. ... 그리고 기타 534 가지 방법
var 메소드 = [
"location.reload ()",
"History.Go (0)",
"location.href = location.href",
"location.href = location.pathname",
"location.replace (location.pathname)",
"location.reload (false)"
]
var $ body = $ ( "본문");
for (var i = 0; i
jQuery가있는 페이지를 다시로드하려면 다음을 수행하십시오.
$.ajax({
url: "",
context: document.body,
success: function(s,x){
$(this).html(s);
}
});
내가 사용한 접근법은 Ajax jQuery였습니다.Chrome 13에서 테스트했습니다. 그런 다음 Reload를 트리거 할 핸들러에 코드를 넣었습니다.URL은 "" "이 페이지를 의미합니다.
답변
현재 페이지가 POST 요청에 의해로드 된 경우 사용할 수 있습니다.
window.location = window.location.pathname;
대신에
window.location.reload();
Window.location.Reload ()는 POST 요청에 의해로드 된 페이지에서 호출 된 경우 확인을 요구합니다.
출처:https://stackoverflow.com/questions/5404839/how-can-i-refresh-a-page-with-jquery
최근댓글