本文實(shí)例講述了Ajax+PHP實(shí)現(xiàn)的模擬進(jìn)度條功能。分享給大家供大家參考,具體如下:
一 代碼
fun.js:
function progress(){
setInterval("beginProgress()", 200);
}
function beginProgress(){
$.get("progress.php", null, function(data){
$("#pg").css("width", data+"%");
$("#pgtext").html("The progress is "+data+"%");
});
}
index.php:
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
html xmlns="http://www.w3.org/1999/xhtml">
head>
meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
title>jQuery制作進(jìn)度條/title>
/head>
script language="javascript" src="js/jquery-1.3.2.js">/script>
script language="javascript" src="js/fun.js">/script>
body>
div style="width:200px; height:12px; border:1px solid #0000FF">
div id="pg" style="width:0%; height:100%;background-color:#0000FF">/div>
/div>
br>
div id="pgtext" style="width:100px; height:20px">/div>
br>
input type="button" value="開(kāi)始" onclick="progress()" />
/body>
/html>
progress.php:
?php
$file = "./count.txt";
$fp = fopen($file, "r");
$txt = fread($fp, filesize($file));
echo $txt;
$fp1 = fopen($file, "w");
if($txt100){
$txt++;
fwrite($fp1, $txt);
}else{
fwrite($fp1, 1);
}
fclose($fp1);
fclose($fp);
?>
二 運(yùn)行結(jié)果

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP+ajax技巧與應(yīng)用小結(jié)》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《PHP基本語(yǔ)法入門(mén)教程》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門(mén)教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫(kù)操作入門(mén)教程》及《php常見(jiàn)數(shù)據(jù)庫(kù)操作技巧匯總》
希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。
您可能感興趣的文章:- PHP+Ajax檢測(cè)用戶名或郵件注冊(cè)時(shí)是否已經(jīng)存在實(shí)例教程
- PHP+AJAX實(shí)現(xiàn)無(wú)刷新注冊(cè)(帶用戶名實(shí)時(shí)檢測(cè))
- php注冊(cè)系統(tǒng)和使用Xajax即時(shí)驗(yàn)證用戶名是否被占用
- PHP+Ajax異步通訊實(shí)現(xiàn)用戶名郵箱驗(yàn)證是否已注冊(cè)( 2種方法實(shí)現(xiàn))
- jQuery ajax+PHP實(shí)現(xiàn)的級(jí)聯(lián)下拉列表框功能示例
- Ajax+PHP實(shí)現(xiàn)的刪除數(shù)據(jù)功能示例
- Ajax+PHP實(shí)現(xiàn)的分類列表框功能示例
- PHP+Ajax實(shí)現(xiàn)的檢測(cè)用戶名功能簡(jiǎn)單示例