location.replace question

D

donet programmer

Wondering if anybody knows how to get around this problem ...

I am creating a "Please wait..." page to show a friendly message to my
site users while the data is being loaded. I am using
location.replace() javascript function to do this.

The problem that I am facing is displaying the records that the
application has already processed on the wait page. Does anybody know
what can I do to pass data field value from the end page where the data
processing is going in background on to the wait page.
 
J

Joshie Surber

I don't know about .net but in most scripting environments the page
will print all output until the script terminates, resulting in a page
that grows as more and more is processed. If this won't do you can use
ajax along with a timeout to query the server about how much data has
been processed.

Unless I completely misunderstood what you want to do... in which case,
you may try pointing to an example on your staging server.
 
D

donet programmer

Thanks Joshie for taking time for helping me out with this problem. I
think you got a good idea of what I am trying to achieve.
My dotnet app has 3 pages StartPage.aspx, WaitPage.aspx and
ResultPage.aspx.

Basic functionality is very simple, I take input from user on
StartPage.aspx.
I pass the input to ResultPage.aspx as a query string.
The result page takes the input and runs a query with that input on db.

[This query fetches around 500 records and takes around 2 min. to
retrieve results].
Until all 500 records are fetched the application just stays on the
StartPage.aspx with a busy icon and progress of the fetch in status bar
of the page.

To eliminate this wait, I introduced a WaitPage.aspx.
When the application starts processing the input on the
ResultPage.aspx, it redirects the user to the wait page. On the wait
page i call following javascript funtion redirectTo() on body onload()
of wait page.

I pass targetPage = "ResultPage.aspx", total = 500 and processed = 0.
This part works great. Now I need to update this value of processed
with the real time actual value of records that are already fetched by
the query which is running on the ResultPage.aspx.


<script>
var i = 0;
var secondsForWaiting = 30;

function redirectTo(targetPage, total, processed)
{

if ( total = 0 )
ProcessingLabel.innerText = "Establishing connection...";


if (0 < targetPage.length)
{
location.replace(targetPage);
b1.style.cursor="wait";
if (secondsForWaiting.valueOf() > 0)
{
ProcessingLabel.innerText =
"This process can take up to "
+ secondsForWaiting + " seconds..."
+ "Total records processed " + processed + " out of " +
total;
timedIterations(secondsForWaiting);
}

}
else
{
ProcessingLabel.innerText = "Page not found."
}
}

function timedIterations(secondsForIterating)
{
incrementalWidth = 600 / secondsForIterating;
if (i <= secondsForIterating + 10)
{
d1.innerText="Elapsed time: " + i + " seconds.";
d2.style.width=i*incrementalWidth;
setTimeout(
"timedIterations(" + secondsForIterating + ");",
1000);
i++;
}
else
{
b1.style.cursor="";
d1.style.visibility = "hidden";
d2.style.visibility = "hidden";
ProcessingLabel.innerText =
"The server is taking longer than "
+ "anticipated to process your request. "
+ "Thank you for your patience. "
+ "You can wait a few minutes longer for "
+ "the process to complete, or you can press "
+ "the back button and try again later...";
}
}
</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,252
Latest member
MeredithPl

Latest Threads

Top