我正在尝试每隔5秒以ajax间隔自动刷新到ID="GridDataSource"
,但是我丢失了一些内容。
这是我的div代码:
div
<script>
function loadlink(){
$('#chart').load(function () {
$(this).unwrap();
});
}
loadlink(); // This will run on page load
setInterval(function(){
loadlink() // this will run after every 5 seconds
}, 5000);
</script>
答案 0 :(得分:1)
您的代码正在运行,您缺少jquery文件
function loadlink() {
console.log("called load link");
$('#chart').load(function () {
$(this).unwrap();
});
}
loadlink(); // This will run on page load
setInterval(function(){
loadlink() // this will run after every 5 seconds
}, 5000);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="chart" >{!! $chart->script() !!}</div>
答案 1 :(得分:1)
您将需要一个文档准备就绪块,以实例化您的 setInterval 函数以使其运行。
较新的jQuery示例:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim t as range, KeyCells As Range
on error goto safe_exit
for each t in target
If t.Value = "" Then
application.enableevents = false
t.Value = 0
End If
MsgBox (t.Value)
next t
Set KeyCells = Range("C3:C10")
safe_exit:
application.enableevents = true
End Sub
或
function loadlink() {
$('#chart').load(function () {
$(this).unwrap();
});
}
$(function() {
loadlink(); // This will run on page load
setInterval(function() {
loadlink() // this will run after every 5 seconds
}, 5000);
});