欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Ajax+PHP實(shí)現(xiàn)的模擬進(jìn)度條功能示例

 更新時(shí)間:2019年02月11日 11:55:03   作者:chengqiuming  
這篇文章主要介紹了Ajax+PHP實(shí)現(xiàn)的模擬進(jìn)度條功能,結(jié)合實(shí)例形式分析了php結(jié)合ajax動(dòng)態(tài)讀取文件實(shí)現(xiàn)進(jìn)度條功能的相關(guān)操作技巧,需要的朋友可以參考下

本文實(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="開始" 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é)果

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP+ajax技巧與應(yīng)用小結(jié)》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《PHP基本語法入門教程》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論