Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Regular Coder
    Join Date
    Aug 2004
    Posts
    367
    Thanks
    10
    Thanked 4 Times in 4 Posts

    Print Please Wait Message While Generating Output

    I have an image manipulation script that takes awhile to generate the output. I want to print to browser a "Please Wait" message during the interim. I tried a print statement at the beginning of the script, but it just waits to display with the other output. I'm not gonna post the code. It's top secret.
    Could someone help me please?
    Last edited by netroact; 07-18-2009 at 04:06 AM.

  • #2
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    I seem to recall that this would require a forked process. It enables a propcess to split into two such that one can be the temp message and the other the actually process you already wrote. when the main process has been completed, then it changes the output message.

    I had a need for it once but couldn't get my head around it. so I am not much help really

    you might find this link helpful but search under 'forking problem'

    serious forking problem
    bazz
    Last edited by bazz; 07-18-2009 at 03:01 AM.
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #3
    New Coder
    Join Date
    Mar 2009
    Location
    Fabric Covered Box
    Posts
    69
    Thanks
    1
    Thanked 16 Times in 14 Posts
    Two possible sources of the delay:

    1. Perl buffering output. In plain CGI stuff, you can use

    $|=1;

    to enable auto-flushing on the active output handle. For more complicated object oriented stuff, check the doc's for an autoflush method or for inheritance from IO::Handle.

    2. Browser don't always render immediately, specially with partial content and unclosed tags. Try wrapping your message in <pre> tags (preformatted means easy to render) or follow it with a <br> or <hr>.

  • #4
    Regular Coder
    Join Date
    Aug 2004
    Posts
    367
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by bazz View Post
    I seem to recall that this would require a forked process. It enables a propcess to split into two such that one can be the temp message and the other the actually process you already wrote. when the main process has been completed, then it changes the output message.

    I had a need for it once but couldn't get my head around it. so I am not much help really

    you might find this link helpful but search under 'forking problem'

    serious forking problem
    bazz
    Thanks for the reply. There might be an answer in that thread, but I'm not smart enough to figure it out.

  • #5
    Regular Coder
    Join Date
    Aug 2004
    Posts
    367
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Shannon Blonk View Post
    Two possible sources of the delay:

    1. Perl buffering output. In plain CGI stuff, you can use

    $|=1;

    to enable auto-flushing on the active output handle. For more complicated object oriented stuff, check the doc's for an autoflush method or for inheritance from IO::Handle.
    Not sure what you are talking about here, but thanks for the reply.


    Quote Originally Posted by Shannon Blonk View Post
    2. Browser don't always render immediately, specially with partial content and unclosed tags. Try wrapping your message in <pre> tags (preformatted means easy to render) or follow it with a <br> or <hr>.
    I have a third party script that prints a please wait message, and then lists the environment variables underneath it. It uses tables and br tags. I tried that formatting, but it didn't work in my script.
    I have since realized that's not what I want anyway. At present the script continues to display the form page until it's ready to display the output. I need the script to immediately display the please wait message until the output is generated, and then display the output on a separate page.
    Appreciate any suggestions.
    Last edited by netroact; 07-18-2009 at 07:48 PM.

  • #6
    Regular Coder
    Join Date
    Aug 2004
    Posts
    367
    Thanks
    10
    Thanked 4 Times in 4 Posts
    I have been searching through the back alleys, and other hidden places. Finally came up with this:

    http://www.stonehenge.com/merlyn/Web...ues/col20.html

    I think I might be able to figure it out over the next few years, but if anyone can adapt it sooner, I would be extremely grateful.

  • #7
    New Coder
    Join Date
    Mar 2009
    Location
    Fabric Covered Box
    Posts
    69
    Thanks
    1
    Thanked 16 Times in 14 Posts
    Let's start with more details: how long does your image manipulation script require? what sort of output do you want? fancy javascripted paged or pure html or just the images itself?

  • #8
    Regular Coder
    Join Date
    Aug 2004
    Posts
    367
    Thanks
    10
    Thanked 4 Times in 4 Posts
    I start with a form page. The user clicks the submit button. I need it to immediately display the message, "Please Wait", so that the user doesn't think the program has hung. Depending upon the form data, the script will run from 2 seconds to 2 minutes.
    I don't need help with the html or the image script. I just need help with running both processes at the same time. The url I referenced above shows how to do this with a search script. I need to adapt it to my script.
    Thanks!
    Last edited by netroact; 07-19-2009 at 05:41 AM.

  • #9
    New Coder
    Join Date
    Mar 2009
    Location
    Fabric Covered Box
    Posts
    69
    Thanks
    1
    Thanked 16 Times in 14 Posts
    Well, let's arbitrarily say you're okay with mandatory javascript (light-weight), and running stateless cgi on some *nix variant...

    I'd have a daemon that reads from a named pipe (blocking when there's nothing to read, of course). cgi gets a request, writes a message to the named pipe. Daemon unblocks/reads message, forks off the manipulation script which sets to work. Meanwhile, the cgi sends a page back to the browser with a 'working...' message and an image, then exits. The image (which doesn't yet exist) has an onerror handler that animates the working messages and then re-requests the image.

    Eventually, the manipulation script finishes and is reaped by the daemon. Once the image exists and is successfully loaded, an onload handler clears the working message and generally tidies up.

    named pipes, daemons, and reaping

  • #10
    Regular Coder
    Join Date
    Aug 2004
    Posts
    367
    Thanks
    10
    Thanked 4 Times in 4 Posts
    I kinda sorta follow everything you said in that post except this:
    Quote Originally Posted by Shannon Blonk View Post
    Eventually, the manipulation script finishes and is reaped by the daemon.
    I no longer have any problems with javascript, since most everyone is using it on the Web now. If you would be willing to provide some example code, I'm sure many people on the Web would appreciate it, since I can't find any specific examples of this anywhere. There are many posts, but very hazy answers.

  • #11
    Banned
    Join Date
    Jul 2009
    Posts
    52
    Thanks
    10
    Thanked 4 Times in 4 Posts
    That's pretty sophisticated Shannon. When I am a billionaire I may have to rent your brain for my perl department.

    Can I suggest to the querant this other route to solving the problem, much less sophisticated:

    Use a (javascript) onclick call in the submit button (for the form you are talking about) which makes a little popup window appear (named) in the middle of the screen at the same time that the form is sent for processing, with a nice graphic saying "please wait..." blah blah - with some nice animation to indicate time passing.

    Then on the output of your cgi have an onload function which closes that popup.

    Presto-hey, job done, problem solved. That will work 100% fine will it not, Shannon, and requires absolutely no tricky sophisticated were-you-born-inside-a-unix-server perl?

  • #12
    Regular Coder
    Join Date
    Aug 2004
    Posts
    367
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by RabidMango View Post
    Use a (javascript) onclick call in the submit button (for the form you are talking about) which makes a little popup window appear (named) in the middle of the screen at the same time that the form is sent for processing, with a nice graphic saying "please wait..." blah blah - with some nice animation to indicate time passing.

    Then on the output of your cgi have an onload function which closes that popup.

    Presto-hey, job done, problem solved. That will work 100% fine will it not, Shannon, and requires absolutely no tricky sophisticated were-you-born-inside-a-unix-server perl?
    I had thought about popping up a prompt on exit, but it would require another click to close the prompt. Never thought about popping up a window with a javascript hyperlink. Not sure how to close the window at the script output though. It wouldn't be a self-close would it? Gonna have to polish up on my javascript.

    Thanks for the reply.

  • #13
    Banned
    Join Date
    Jul 2009
    Posts
    52
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Code:
    Javascript window.open, also fullscreen and centered popup window ...
    <a href="javascript: void(0)" onclick="window.open('popup.html', 'windowname1', 'width=200, height=77'); return false;">Click here for simple popup ...
    javascript-array.com/scripts/window_open/ - Cached - Similar
    (I just snipped that right off a google search, as you can see)

    This page seems to have the appropriate facts relating to closing the window again:
    http://www.javascript-coder.com/wind...ow-close.phtml

    Since the window is given a name, then on the new page that loads you can just put some javascript in closing the window which has that name the moment the page has loaded.

  • #14
    Regular Coder
    Join Date
    Aug 2004
    Posts
    367
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Thanks! I'll look into that.

  • #15
    New Coder
    Join Date
    Mar 2009
    Location
    Fabric Covered Box
    Posts
    69
    Thanks
    1
    Thanked 16 Times in 14 Posts
    Grrr. Simple solutions! How can you expect to be promoted to upper-middle project management without a dozen inter-dependent processess in at least four layers?

    Yeah, ignore what I suggested earlier... I've been to too many meetings this week -- it's making my brain enterprisey.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •