我遇到了一个与以前的问题类似的问题,但现在是不同的
jquery:进度条显示在html 中
var auto_refresh = setInterval(
function ()
{
$('#battery').load('https=://localhost/userinfo/battery_level/');
}, 10000);
我不想加载div。。。我想得到结果,并想在我的进度栏中显示
$('.demo-progress').progress(data);
我在这里得到一个值"10"
想做一些类似的事情
var auto_refresh = setInterval(
function ()
{
var data = $('#battery').load('https=://localhost/userinfo/battery_level/');
}, 10000);
$('.demo-progress').progress(data);
试试这个:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" type="text/css" rel="Stylesheet" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(function () {
$("#progressbar").progressbar({ max: 100, value: 10 });
$("#twenty").click(function () { loadFile("20"); });
$("#fifty").click(function () { loadFile("55"); });
$("#eighty").click(function () { loadFile("80"); });
});
function loadFile(file) {
$.get(file + ".txt", function (data) {
var value = parseInt(data, 10);
$('#progressbar').progressbar("option", "value", value);
});
}
</script>
</head>
<body>
<div id="progressbar">
</div>
<input type="button" id="twenty" value="Load to 20%" />
<input type="button" id="fifty" value="Load to 50%" />
<input type="button" id="eighty" value="Load to 80%" />
</body>
</html>
从jquery页面:
此方法(.load)是从服务器获取数据的最简单方法。它大致相当于$.get(url、data、success),只是是一个方法而不是全局函数,并且它有一个隐式回调函数。
我之所以使用.get,是因为最后一部分,即隐式回调函数,它让我知道函数何时结束,然后我可以更新进度条。