I realize there are a good number of progress bar related questions already present on SO. I browsed through many of them and was unable to get things working.
Simply put, I am developing a page in JSP and I want to use an animated progress bar within bootstrap to display while the calls are being made for the data.
HTML:
<div class="row-fluid"> <div class="span12 progress progress-striped active"> <div id="searchAnimation" class="bar" hidden="true"></div> </div> </div> Servlet (Not sure if this part is relevant, but better safe than sorry):
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //String that gets returned as HTML StringBuilder returnAsHTML = new StringBuilder(); //See if the class is closed, has a lab, or is just a regular class for(ClassInfo classes : springClassListings) { //Class is full, style accordingly if(classes.getSectionMeetingInfo().contentEquals("LEC") && classes.getSectionEnrolled().contentEquals("0")) { returnAsHTML.append(closedClass(classes)); } else if(classes.getSectionMeetingInfo().contentEquals("LAB")) //These are labs, style accordingly { returnAsHTML.append(labClass(classes)); } else //These are normal classes without lab components { returnAsHTML.append(openClass(classes)); } } response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(returnAsHTML.toString()); } And my scripting:
//Serves up the data $('#btnData').click(function() { //THIS IS THE PROGRESS BAR $("#searchAnimation").show(); $.get('daoServlet', function(responseText) { $('#dataDisp').html(responseText); }); }); I get the idea, % the width of the progress bar by a where the $.get call is at in terms of getting the data. I just don't understand how to do it.
PS - I know my for/if in the doGet is a nasty anti pattern, I just haven't figured out a way around it yet.