javascript - Why does AJAX (reload div every x time) not work?
问题描述
I want to reload a div every x time. This is what I have so far:
HTML:
<div class="col-sm-6" id="myDesign" id="show">
<h3>Show my cars:</h3>
<?php $controller->getEvents(); ?>
</div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
JS:
* ...In a document ready function... *
setInterval(function () {
$('#show').reload()
}, 3000);
I think my reload function ist not correct at the "$('#show').reload()" line.
解决方案
You have to use the load function:
setInterval(function(){
$('#show').load('/path/to/server/source');
}, 2000) /* time in milliseconds (ie 2 seconds)*/
推荐阅读
- server - Livecode - 使客户端在丢失连接时自动重新连接
- java - Consul Health 指示器未显示在 SpringBoot 的执行器健康端点中
- mysql - 使用 REGEXP_SUBSTR 从字符串中获取日期值
- javascript - 在功能组件反应的 OnChange 输入中传递参数对象
- continuous-integration - gitlab runner:以退出状态0杀死另一个作业
- python - 如何从python中的字符串中检测正确的变量
- docker-compose - exec 用户进程导致“exec 格式错误”
- angular - Core + Angular After Production Build 无法访问资产文件夹文件
- angular - 使用字符串连接在 ngClass 中添加多个类
- python-3.x - 从零开始在 Python 中实现随机梯度下降。实施是否正确?