메시지가 표시된 후 페이지 다시 로드, jQuery
지금은 사용자가 정보를 입력하는 양식이 있습니다.이것은 처리된 bujQuery agax 함수보다 더 크며 다음과 같이 설정됩니다.return false;
사용자가 양식을 제출한 후 페이지 다시 로드가 발생하지 않습니다.페이지를 다시 로드해야 하지만 제거하면return false;
성공 메시지가 표시되기 전에 페이지를 새로 고칩니다(이 메시지는 사용자가 데이터를 제출한 후에 표시됨).
$.ajax({
type: "POST",
url: "scripts/process.php",
data: dataString,
success: function() {
$("#st_message").html("<p> Your article was successfully added!</p>");
//I need to reload page after the above message is shown
}
});
return false;
그래서 어떻게 하면 다음 페이지를 다시 로드할 수 있습니까?<p> Your article was successfully added!</p>
사용자가 실제로 메시지를 읽을 수 있도록 약간의 지연과 함께 2 - 3초로 표시됩니다.
다음과 같은 기능을 사용하여 지연을 추가할 수 있습니다.
// This will reload the page after a delay of 3 seconds
window.setTimeout(function(){location.reload()},3000)
사용자 요구사항:
$.ajax({
type: "POST",
url: "scripts/process.php",
data: dataString,
success: function() {
$("#st_message").html("<p> Your article was successfully added!</p>");
window.setTimeout(function(){location.reload()},3000)
}
});
return false;
다음과 같은 작업을 수행합니다.
function delayedRedirect(){
window.location = "/index.php"
}
setTimeout('delayedRedirect()', 3000)
setTimeout
는 리디렉션 함수 호출을 지연시키는 데 사용되며, 이 경우 새 URL로 리디렉션할 수 있습니다(필요한 경우에 대비하여).
그렇지 않으면 사용location.reload()
페이지를 다시 로드합니다.
사용setTimeout
지연을 얻는 방법, 그리고reload
페이지를 다시 로드하는 방법입니다.참고:true
의 매개 변수reload
캐시에서 다시 칠하는 것이 아니라 페이지가 실제로 다시 로드되었는지 확인하기 위해 호출합니다.
window.setTimeout(
function(){
location.reload(true)
},
3000
);
다음과 같은 것을 의미합니까?window.location.reload()
자바스크립트로
을 이용하여 해 보다.
setTimeout("window.location='yourpage.php'",3000);
사용자 코드:
$.ajax({
type: "POST",
url: "scripts/process.php",
data: dataString,
success: function() {
$("#st_message").html("<p> Your article was successfully added!</p>");
setTimeout("window.location='yourpage.php'",3000);//reload after 3 sec.
}
});
return false;
시간 초과를 사용하는 것은 정말 나쁜 생각입니다.
$.ajax({
type: "POST",
url: "scripts/process.php",
data: dataString,
success: function() {
var miliseconds = 2000;
$("#st_message").html("<p> Your article was successfully added!</p>");
setTimeout("window.location=window.location", miliseconds);
//I need to reload page after the above message is shown
}
});
<script type="text/javascript">
//
//your action here
//
window.setTimeout(function(){self.parent.location="?list"},3000);//after 3 sec go to (?list or example.html page)
return false;
</script>
예:
success: function(data){
$("#loading-img").css("display","none");
swal({
title: "Félécitations",
text: "Votre demande a été transmise au service concerné",
icon: "success",
button: "OK",
});
window.setTimeout(function(){location.reload(true)},3000)
}
});
return false;
}
언급URL : https://stackoverflow.com/questions/8404970/reload-page-after-message-is-shown-jquery
'programing' 카테고리의 다른 글
어떻게 하면 녹아웃 JS가 초점 손실 대신 키 누름으로 데이터를 바인딩할 수 있습니까? (0) | 2023.09.08 |
---|---|
파워쉘 안에서 키스트로크를 수행하는 방법은? (0) | 2023.09.08 |
커밋 메시지 없이 Git 커밋 (0) | 2023.09.03 |
mariadb: 업데이트에서 "IN" 폐쇄 쿼리 실행 (0) | 2023.09.03 |
AVPlayer 개체를 재생할 준비가 된 시점 확인 (0) | 2023.09.03 |