468,107 Members | 1,410 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,107 developers. It's quick & easy.

How to hit a server in the background?

We're designing a web app in which some operations will take a long time
to complete (maybe two minutes). Because it's a high-volume application,
we don't want browser connections hanging open for these two-minute
intervals; that would cause a huge resource drain on the server (open
threads, etc.).

We've implemented a page which has a <meta refresh> tag in it of 15
seconds, so that the browser can "check back" with the server every so
often to see if it's done with this operation.

However, we don't like the constant page reloading.. We'd rather script
this as a javascript "background process" if this is possible...

My question is, is there a way to script some kind of page reload in
Javascript, which is done without any visible window on the screen? I'd
script it to reload every 15 seconds or so, until (for example) the text
"OK" appears in the <body> tag (or some other indicator), which would
then signal the main page to reload.

Sorry if this is a tortuously confusing question. Appreciate it if you
got this far and can offer any suggestions.
--

Bryan Field-Elliot
http://netmeme.org

Jul 20 '05 #1
5 4392
I'd like to see more pages doing this kind of thing.

One thing you can do is to have an IFrame and set its source to be something like
mydomain.com/perhaps/a/directory/statusChecker.php?some=arguments&go=here

On the server side, you will then realize that this is a directive to check some status.
If it's ready, return appropriate data, otherwise send back a not ready message.
This sending back data/message is actually a page which has an onLoad
which knows about its container document (the original page)
and can access the necessary functions.

You'll have timing issues (but then again, that's your whole
reason for doing this). In particular, You'll have to have some
timeout and set semaphores in case the server or connection
goes belly up, or the response time is longer than expected
and then returning.

Good luck,
Csaba Gabor from New York

PS. You can do one way communication by setting the src on
IMAGE elements, but you have said that you actually want
returned information.
You would think that you could just load a new SCRIPT element
instead of needing to suck up pages, but I have not gotten this
to work, especially cross platform. I'd be happy to read about
other peoples' approaches.
"Bryan Field-Elliot" <br***@netmeme.org> wrote in message news:3LQ9b.481514$o%2.214880@sccrnsc02...
We're designing a web app in which some operations will take a long time
to complete (maybe two minutes). Because it's a high-volume application,
we don't want browser connections hanging open for these two-minute
intervals; that would cause a huge resource drain on the server (open
threads, etc.).

We've implemented a page which has a <meta refresh> tag in it of 15
seconds, so that the browser can "check back" with the server every so
often to see if it's done with this operation.

However, we don't like the constant page reloading.. We'd rather script
this as a javascript "background process" if this is possible...

My question is, is there a way to script some kind of page reload in
Javascript, which is done without any visible window on the screen? I'd
script it to reload every 15 seconds or so, until (for example) the text
"OK" appears in the <body> tag (or some other indicator), which would
then signal the main page to reload.

Sorry if this is a tortuously confusing question. Appreciate it if you
got this far and can offer any suggestions.
--

Bryan Field-Elliot
http://netmeme.org

Jul 20 '05 #2
This is clever, thank you. The returned "Status" document can contain
the javascript needed to cause the parent to reload (after the server is
done processing). Nice!

So I guess the last follow-on question is, if an IFRAME has a width and
a height of "0", does it cause any funny stuff to happen in any of the
popular browsers, or is it fine?
--

Bryan Field-Elliot
http://netmeme.org


Csaba2000 wrote:
I'd like to see more pages doing this kind of thing.

One thing you can do is to have an IFrame and set its source to be something like
mydomain.com/perhaps/a/directory/statusChecker.php?some=arguments&go=here

On the server side, you will then realize that this is a directive to check some status.
If it's ready, return appropriate data, otherwise send back a not ready message.
This sending back data/message is actually a page which has an onLoad
which knows about its container document (the original page)
and can access the necessary functions.

You'll have timing issues (but then again, that's your whole
reason for doing this). In particular, You'll have to have some
timeout and set semaphores in case the server or connection
goes belly up, or the response time is longer than expected
and then returning.

Good luck,
Csaba Gabor from New York

PS. You can do one way communication by setting the src on
IMAGE elements, but you have said that you actually want
returned information.
You would think that you could just load a new SCRIPT element
instead of needing to suck up pages, but I have not gotten this
to work, especially cross platform. I'd be happy to read about
other peoples' approaches.
"Bryan Field-Elliot" <br***@netmeme.org> wrote in message news:3LQ9b.481514$o%2.214880@sccrnsc02...
We're designing a web app in which some operations will take a long time
to complete (maybe two minutes). Because it's a high-volume application,
we don't want browser connections hanging open for these two-minute
intervals; that would cause a huge resource drain on the server (open
threads, etc.).

We've implemented a page which has a <meta refresh> tag in it of 15
seconds, so that the browser can "check back" with the server every so
often to see if it's done with this operation.

However, we don't like the constant page reloading.. We'd rather script
this as a javascript "background process" if this is possible...

My question is, is there a way to script some kind of page reload in
Javascript, which is done without any visible window on the screen? I'd
script it to reload every 15 seconds or so, until (for example) the text
"OK" appears in the <body> tag (or some other indicator), which would
then signal the main page to reload.

Sorry if this is a tortuously confusing question. Appreciate it if you
got this far and can offer any suggestions.
--

Bryan Field-Elliot
http://netmeme.org



Jul 20 '05 #3
"Bryan Field-Elliot" <br***@netmeme.org> wrote in message news:0r*******************@rwcrnsc52.ops.asp.att.n et...
This is clever, thank you. The returned "Status" document can contain
the javascript needed to cause the parent to reload (after the server is
done processing). Nice!
Or, the returned "Status" document can contain the javascript needed to
REPAINT or reconfigure the page, IF there is not much change, which
will reduce the amount of flicker the user sees
So I guess the last follow-on question is, if an IFRAME has a width and
a height of "0", does it cause any funny stuff to happen in any of the
popular browsers, or is it fine?
I seem to recollect that there are some issues with the visibility of the
IFrame, but I don't remember details. One option is to set
..style.display="none" on it. If I remember right, trying to set
focus to one of its elements when the element is not visible hangs
the page on one browser (probably NN), but I'm not sure on that.
The upshot is, you'll have to be on the lookout for issues.
Also, didn't I see that Opera allows you to permit inline frames
or not - but frankly, even if true, I think market share on this
is so small you needn't worry.

Csaba

PS. I almost forgot another idea (but I like the IFrame one better).
I think (I'm not sure - my testing was a while ago), that you could
set cookies when sending information by means of altering
the src on an IMAGE element. This would allow passive
(where the returned data can't notify the requester - which is
why I'd use the IFrame) communication of limited size. It doesn't
strike me as being structurally more simple, however, than
the IFRAME scheme.
--

Bryan Field-Elliot
http://netmeme.org


Csaba2000 wrote:
I'd like to see more pages doing this kind of thing.

One thing you can do is to have an IFrame and set its source to be something like
mydomain.com/perhaps/a/directory/statusChecker.php?some=arguments&go=here

On the server side, you will then realize that this is a directive to check some status.
If it's ready, return appropriate data, otherwise send back a not ready message.
This sending back data/message is actually a page which has an onLoad
which knows about its container document (the original page)
and can access the necessary functions.

You'll have timing issues (but then again, that's your whole
reason for doing this). In particular, You'll have to have some
timeout and set semaphores in case the server or connection
goes belly up, or the response time is longer than expected
and then returning.

Good luck,
Csaba Gabor from New York

PS. You can do one way communication by setting the src on
IMAGE elements, but you have said that you actually want
returned information.
You would think that you could just load a new SCRIPT element
instead of needing to suck up pages, but I have not gotten this
to work, especially cross platform. I'd be happy to read about
other peoples' approaches.
"Bryan Field-Elliot" <br***@netmeme.org> wrote in message news:3LQ9b.481514$o%2.214880@sccrnsc02...
We're designing a web app in which some operations will take a long time
to complete (maybe two minutes). Because it's a high-volume application,
we don't want browser connections hanging open for these two-minute
intervals; that would cause a huge resource drain on the server (open
threads, etc.).

We've implemented a page which has a <meta refresh> tag in it of 15
seconds, so that the browser can "check back" with the server every so
often to see if it's done with this operation.

However, we don't like the constant page reloading.. We'd rather script
this as a javascript "background process" if this is possible...

My question is, is there a way to script some kind of page reload in
Javascript, which is done without any visible window on the screen? I'd
script it to reload every 15 seconds or so, until (for example) the text
"OK" appears in the <body> tag (or some other indicator), which would
then signal the main page to reload.

Sorry if this is a tortuously confusing question. Appreciate it if you
got this far and can offer any suggestions.
--

Bryan Field-Elliot
http://netmeme.org


Jul 20 '05 #4
Bryan Field-Elliot wrote:
We're designing a web app in which some operations will take a long time
to complete (maybe two minutes). Because it's a high-volume application,
we don't want browser connections hanging open for these two-minute
intervals; that would cause a huge resource drain on the server (open
threads, etc.).

We've implemented a page which has a <meta refresh> tag in it of 15
seconds, so that the browser can "check back" with the server every so
often to see if it's done with this operation.

However, we don't like the constant page reloading.. We'd rather script
this as a javascript "background process" if this is possible...

My question is, is there a way to script some kind of page reload in
Javascript, which is done without any visible window on the screen? I'd
script it to reload every 15 seconds or so, until (for example) the text
"OK" appears in the <body> tag (or some other indicator), which would
then signal the main page to reload.

[...]


Could the HTTPRequest object be useful for this?

http://jibbering.com/2002/4/httprequest.html

Regards,
Stephen

Jul 20 '05 #5
Hi all,

I have the same problem,

I need make a controler with javascript for background process.

My app registration values and take a 1 minutes if the user press f5 or button post
the process start again.

Can i controle this?

Thanks
Jul 28 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Marek Kotowski | last post: by
19 posts views Thread by Thue Tuxen Sørensen | last post: by
2 posts views Thread by VB Programmer | last post: by
4 posts views Thread by Weston Weems | last post: by
3 posts views Thread by nathanwb | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.