使用 Jquery 更新 div 标签
我想更新包含饼图的 div 标签(Holder),每次加载页面时我都会将值发送到饼图(ResponseMetric.aspx)。我使用 jQuery 来仅更新 div 标签(holder),但没有任何反应,我更改了数据库中的值,以便在页面加载时传递新值。它不执行任何页面加载。饼图中的值保持不变,这是我出错的地方。
<script type="text/javascript" src="scripts/jquery.js"/>
<script type="text/javascript">
function getRandom() {
$("#holder").hide("slow");
$("#holder").load("ResponseMetric.aspx", '', callback);
}
function callback() {
$("#holder").show("slow");
setTimeout("getRandom();", 4000);
}
$(document).ready(getRandom);
</script>
页面加载时,我将值传递到 Holder (Div) 标记内的饼图。饼图的数据每秒都会变化,所以基本上饼图必须每 4 秒更新一次,但它不会
I want to update a div tag(Holder) which contains a pie chart, I send values to the pie chart everytime the page loads (ResponseMetric.aspx). I am using jQuery for that purpose to update only the div tag(holder) but nothing happens, I change the value in the DB so that on page load a new value is passed. It doesnt do any page load. the values in the pie chart remains the same, where I am going wrong.
<script type="text/javascript" src="scripts/jquery.js"/>
<script type="text/javascript">
function getRandom() {
$("#holder").hide("slow");
$("#holder").load("ResponseMetric.aspx", '', callback);
}
function callback() {
$("#holder").show("slow");
setTimeout("getRandom();", 4000);
}
$(document).ready(getRandom);
</script>
On page load I pass the values to the pie chart which is inside the Holder (Div) tag. the data for the pie chart changes every second so basically the pie chart has to be updated every 4 seconds, but it does not
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我尝试了你的代码,只在 jsfiddle 中做了一些细微的修改
,这对我有用,请注意,唯一的区别实际上不是字符串封装 setTimeout 中的函数调用
I tried your code and did only slight modifications in a jsfiddle
And this worked for me, notice the only difference really being not string-encapsulating the function call in setTimeout