189 8069 5689

AJAX中怎么实现一个进度条效果-创新互联

AJAX中怎么实现一个进度条效果,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

创新互联建站专注于吴川企业网站建设,响应式网站开发,商城网站建设。吴川网站建设公司,为吴川等地区提供建站服务。全流程定制网站,专业设计,全程项目跟踪,创新互联建站专业和态度为您提供的服务

效果如下:
AJAX中怎么实现一个进度条效果


 代码如下:





Ajax Progress Bar



Ajax Progress Bar Example


Launch long-running process:











   
   
   
   
   
   
   
   
   




代码如下:


package cn.Ajax.test;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@SuppressWarnings("serial")
public class ProgressBarServlet extends HttpServlet {
private int counter = 1;

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String task = request.getParameter("task");
String res="";
if(task.equals("create")){
res = "1";
counter = 1;
}
else{
String percent = "";
switch (counter) {
case 1: percent = "10";break;
case 2: percent = "23";break;
case 3: percent = "35";break;
case 4: percent = "51";break;
case 5: percent = "64";break;
case 6: percent = "73";break;
case 7: percent = "89";break;
case 8: percent = "100";break;
}
counter++;
res =""+percent+"";
}
PrintWriter out = response.getWriter();
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
out.println("");
out.println(res);
out.println("
");
out.close();
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}


关于AJAX中怎么实现一个进度条效果问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联行业资讯频道了解更多相关知识。


名称栏目:AJAX中怎么实现一个进度条效果-创新互联
转载来源:http://cdxtjz.cn/article/jsped.html

其他资讯