How can I add a "loading" graphic to this page while my SELECT runs?

I've got a SELECT running that takes a while to complete.

I want to run a "spinner" graphic while the SELECT is cooking. I've found loading graphics that handle uploads and form submissions, but I don't see anything that addresses my situation specifically. Maybe I'm looking right at it and I just don't see it.

I'm retrieving about 4,000 rows. It takes about 15-20 seconds. How can I get a little animation to show while this is going on?
brucegustPHP DeveloperAsked:
Who is Participating?
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
You don't.  The 'onload' doesn't happen until the page is loaded.  It also can not listen for the end or even existence of any PHP anything because it is JavaScript in the browser.  PHP will be done running before you even see it.  That's why you run it in the previous page so it will be on the screen until the new page loads.
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
It's actually very simple.  Create a hidden element containing your graphic.  Add an 'onclick' action to the element that starts the SELECT that unhides the graphic.  The graphic sits and spins until the new page loads.  I see a lot of 'fancy' versions using AJAX but that's overly complicated.
mohan singhConnect With a Mentor Web developerCommented:
You can use ajax or JavaScript function for your requirements

use this link

also you can use
create page loader and include it where you want to use
and change url image of gif it will work

.loader {
	position: fixed;
	left: 0px;
	top: 0px;
	width: 100%;
	height: 100%;
	z-index: 114; 
    opacity: 1;
    backface-visibility: hidden; 
    background: url('gif/Wedges.gif') 50% 50% no-repeat rgb(249,249,249);
<div class="loader">
       	<!-- Javascript -->
	<script src="js/jquery-2.1.4.min.js"></script>
   <script type="text/javascript">
$(window).load(function() {

Open in new window

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

brucegustPHP DeveloperAuthor Commented:
Guys, I think we're poised on the threshold of great things, but here's the thing:

My user is going to click on a link that opens up another page. It's on that page where the loader needs to kick in. If I'm reading your recommendations correctly, it looks as though the route you're suggesting is a scenario where the user is on a page, clicks a button and the SELECT and the loader are initiated from that page as opposed to opening something up in a brand new session / window.

How do I get a loader to happen in an "onload" context and have it listening for the end of a PHP SELECT?
brucegustPHP DeveloperAuthor Commented:
Got it!

Thank you, boys!
brucegustPHP DeveloperAuthor Commented:
What constituted the bottom line for me was understanding how the loading dynamic was actually a hidden div that was "shown" once you hit the link that opens the page you know is going to take a while to load. Once I understood that sequence, all was gold.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.