0
我们正在使用JQuery UI进行ProgressBar。我们正面临一些问题,我们没有从PHP获得价值。我们无法创建一个可以将值返回给基于Ajax的代码的数字循环。我们如何在PHP中回显进度条的数据?
下面是我们的代码:
HTML
<!DOCTYPE html>
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<style type="text/css">
#bardivs {
width:400px; /* or whatever the of the porgress bar is */
/*
The position of #bardivs must be something other than
static (the default) so that its children will be positioned
relative to it.
*/
position:relative;
}
#progresstext {
position:absolute;
top:0;
left:0;
}
</style>
<script>
var url = "http://localhost/sample/data.php";
$(function() {
var progress = 0;
//alert("some value" + value, value);
$("#progressbar").progressbar({ progress: 0 });
setTimeout(updateProgress, 500);
});
function updateProgress() {
var progress;
$.get(url, function(data) {
// data contains whatever that page returns
if (data < 100) {
$("#progressbar").progressbar("option", "value", data);
$("#progresstext").html("<p> Loading...<p>");
setTimeout(updateProgress, 500);
} else {
$("#progressbar")
.progressbar("option", "value", 100);
}
});
}
</script>
</head>
<div id="bardivs">
<div id="progressbar"></div>
<div id="progresstext"></div>
</div>
</html>
我们没有任何想法,我们如何可以使PHP代码中使用此加载功能。它应该在一个循环中。
脚本如何看起来你已经尝试过? –
有没有错误? ajax请求是否提供了一些东西? – Zlatev
我们已经在互联网上的某处复制了它。我们正在寻找这种类型的功能,但我们无法在PHP中创建脚本来激活它。就像我们需要循环中的一个数字,如0-100,并且它应该使用Ob_start(),ob_end_clean()在单个回声中。我们无法将所有这些事情汇总在一起...... – PPS