如何在PHP中使用Ajax模擬一個(gè)進(jìn)度條功能?相信很多沒有經(jīng)驗(yàn)的人對(duì)此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個(gè)問題。

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 > <div id="pg" ></div> </div> <br> <div id="pgtext" ></div> <br> <input type="button" value="開始" 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($txt<100){
$txt++;
fwrite($fp1, $txt);
}else{
fwrite($fp1, 1);
}
fclose($fp1);
fclose($fp);
?>二 運(yùn)行結(jié)果

看完上述內(nèi)容,你們掌握如何在PHP中使用Ajax模擬一個(gè)進(jìn)度條功能的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
本文標(biāo)題:如何在PHP中使用Ajax模擬一個(gè)進(jìn)度條功能-創(chuàng)新互聯(lián)
文章來源:http://chinadenli.net/article12/dphogc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、微信小程序、網(wǎng)站建設(shè)、關(guān)鍵詞優(yōu)化、網(wǎng)站制作、用戶體驗(yàn)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容