매개 변수를 보내고 데이터를 표시하는 작은 검색 필드가 포함될 보고서를 개발 중입니다. 그러나 특정 시간마다 업데이트해야하거나 더 많은 레코드가 표시 될 때 어떻게 자동 업데이트 할 수 있습니까? 같은 매개 변수를 가진 보고서?자동으로 업데이트하는 방법?
0
A
답변
0
위치 재로드와 함께 일부 시간 초과 js 기능을 추가하여 매 x 분마다 페이지를 다시로드 할 수 있습니다. 예 :
<script>
setTimeout(function(){ document.location.reload() }, 300000);
</script>
0
예, 당신은 자동으로 주기적으로 timeout
및 ajax
요청을 사용하여 보고서의 페이지를 업데이트 할 수 있습니다. 당신의 page.js에서
$(document).ready(function() {
setTimeout(function(){
$.ajax({
url: '/report', # Write url of your request API
type: "GET",
data: data, # Pass data here, as a parameter
dataType: "JSON",
}).done(function(data) {
# Do stuff here
}
}, 5000); # Set the time as you wish, this will execute at every 5 seconds
});
업데이트 아약스 전화 응답에 대한
$(document).ready(function() {
window.setInterval(function(){
$.ajax({
url: '/report.js', # Write url of your request API
type: "GET",
data: data # Pass data here, as a parameter
}).done(function(data) {
# Do stuff here
}
}, 5000); # Set the time as you wish, this will execute at every 5 seconds
});
@maximilian 덕분에, 대신 전체 페이지를 다시로드, 그것은 만에 의해 다시로드 될 가능성이있다 아약스와 마지막 매개 변수는 검색 엔진에서 입력 한? – luis31