Avatar of dcjsdts
 asked on

Timed message box while page loads due to long query

Hi folks - here's my situation.  I submit my form which queries 3 databases to build my end result.  Everything works fine and what I currently do is just an ALERT that after clicking the submit button it may take up to 10 seconds to return your result.

What I would like is something for them to see or ead during this approximate 10 second wait.  As soon as they click OK, the queries run and the new results page loads once it receives the reqults from my one query which takes 5 - 10 seconds on a good day.  I'd like to display something for 10 seconds (10 seconds to make it easy) or display an intermediate page or php echoed message until the page does load.

I was thinking I could do a static timed popup using window.onLoad?  But I know there has to be a better way to make this autodismiss once the page populates with data.

Any ideas welcome.  Thanks in advance!!
function OpenForm(rid, tid){
var myRID = rid;
var myFTech = tid;
alert('This may take up to 10 seconds to redirect while the databases are queried.\r\n\nPlease Click Ok to continue.');
window.location="weekly_edit.php?dofunction=edit_form&idno=" + myRID + "&tech=" + myFTech;

Open in new window


Avatar of undefined
Last Comment

8/22/2022 - Mon
Sandeep Kothari

10 seconds is too loooooong time to wait for any result on internet atleast..... anyways idea... why dont you show them ajax loading....or percentage bar. ... 0 to 100% loading ...

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Thanks folks..

I'm a little confused by document getlelemntbyID "pw"

Where is the ID of PW in the current/first page(s)?

Sorry, duh - I didnt read it entirely...  I will fiddle with this for a while.  Looks like we're on the right track.

I was thinking about a do while loop and when one of my values returned from my slow DB is no longer null, it would simply stop echoing "sorry for the delay...."   This seems much better!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck

Ok, I got it all working and it works great.  One question:  Why do I need the JS function and the image in the weekly_edit page, especially since style.display = "none"?

Anyhow, with it just in the weekly_search everything works great.  Thank you very much!  Thank you also, kshna for your quick response.

Wonderful!  Much appreciated.