php进度条
2015-06-17 08:07
531 查看
php进度条
效果图
long_process.php
<?php
for($i=1;$i<=10;$i++){
session_start();
$_SESSION["progress"]=$i;
session_write_close();
sleep(1);
}
process.php
<?php
session_start();
echo $_SESSION["progress"];
index.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="http://www.localhost.com/jquery.js"></script>
<style>
#container{
position:relative;
width:400px;
height:30px;
line-height:30px;
text-align:center;
background:#999;
}
#progress{
background:#399;
width:0;
}
#percent{
position:absolute;
top:0;
left:190px;
}
</style>
</head>
<body>
<div id="container">
<div id="progress"> </div>
<div id="percent"></div>
</div>
</body>
<script>
$.ajax({
url:'long_process.php',
success:function(data){}
});
function getProgress(){
$.ajax({
async:false,
url:'progress.php',
success: function(data){
var w1=(parseInt(data)*400/10)+'px';
var w2=(parseInt(data)/10*100)+'%';
$("#progress").css({width:w2});
$("#percent").html(w2);
if(data==10){
clearInterval(timer);
}
}
});
}
var timer=setInterval(function(){
getProgress();
},1000);
</script>
</html>
效果图
long_process.php
<?php
for($i=1;$i<=10;$i++){
session_start();
$_SESSION["progress"]=$i;
session_write_close();
sleep(1);
}
process.php
<?php
session_start();
echo $_SESSION["progress"];
index.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="http://www.localhost.com/jquery.js"></script>
<style>
#container{
position:relative;
width:400px;
height:30px;
line-height:30px;
text-align:center;
background:#999;
}
#progress{
background:#399;
width:0;
}
#percent{
position:absolute;
top:0;
left:190px;
}
</style>
</head>
<body>
<div id="container">
<div id="progress"> </div>
<div id="percent"></div>
</div>
</body>
<script>
$.ajax({
url:'long_process.php',
success:function(data){}
});
function getProgress(){
$.ajax({
async:false,
url:'progress.php',
success: function(data){
var w1=(parseInt(data)*400/10)+'px';
var w2=(parseInt(data)/10*100)+'%';
$("#progress").css({width:w2});
$("#percent").html(w2);
if(data==10){
clearInterval(timer);
}
}
});
}
var timer=setInterval(function(){
getProgress();
},1000);
</script>
</html>
相关文章推荐
- PHP版本的讲解
- php oci8 小试
- 《PHP面向对象编程详解》系列技术文章整理收藏
- PHP面向对象编程详解:类和对象
- 一把鼻涕一把泪 搭建公网ftp服务器
- PHP封装的HttpClient类用法实例
- php使用CURL不依赖COOKIEJAR获取COOKIE的方法
- PHP基于MySQL数据库实现对象持久层的方法
- PHP实现的购物车类实例
- php准确获取文件MIME类型的方法
- PHP排序算法类实例
- php正则替换处理HTML页面的方法
- php源码分析之DZX1.5随机数函数random用法
- php源码分析之DZX1.5加密解密函数authcode用法
- php源码分析之DZX1.5字符串截断函数cutstr用法
- PHP实现在线阅读PDF文件的方法
- PHP实现HTTP断点续传的方法
- HP-UX下限制/允许ftp/telnet的方法
- web安全如何系统学习研究
- php Hash函数了解