Jump to content

Make a nice simple please wait page display...


bobthebullet990

Recommended Posts

Hi guys, looking for some help...

 

Bascially what I'm doing is:

 

- Get data

- Validate data

- Create temporary config file

- Run an external Perl Script using the php shell_exec command (requires the temp config file)

- PROBLEM STAGE - Do something whilst script executes

- Finished

 

Trouble is, when I do this, when the script is running its output is invisible to the client machine (obviously as its running on the server)... However, the script takes about 10 minutes to complete and there is some usefull output from the Perl script that would benefit the user; currently I can only produce this output once the script completes, but in the meantime I'm left with a page that appears to be doing nothing whilst it waits for the script to complete!

 

 

Can I either:

- Generate a simple html page that displays a please wait graphic until the script completes

- Route the output of the perl script to the client browser so they can see what is happening

 

 

Many thanks in advance!

Link to comment
Share on other sites

What I do is make a function called loading(), which hides and unhides a div that says Loading....

 

function loading() {
  var load;
  load = document.getElementById("loading");
  vis = load.style;
  if(vis.display == '' || vis.display == 'block') {
    vis.display = 'none';
    } else if(vis.display == 'none') {
    vis.display = 'block';
    }
  }

 

Then just put a stylized div on your page:

 

<div style="position:absolute;right:2px;top:2px;background-color:#1a520b;padding:2px;border:1px solid black;display:none;" id="loading"><b>Loading...</b></div>

 

You can change this to whatever you want, but right now it'll have this color background, black text, a 1 pixel border, and will be situated at the top-right 2 pixels from the corner.

 

I'd recommend centering it on the page and making the rest of the page fade, sort of duplicating a modal dialog.  It wouldn't take too much modification.

 

Anyways, I have that function iside my xmlhttp.js file, the file that contains the javascript to make the AJAX request, and in the function that I call to start the request I just put a loading() right before I make the request, and then right before the data gets given back to the page that requested it, I call loading() again, which hides the box.

 

Does that make any sense at all?

Link to comment
Share on other sites

Sorry, I'm not familiar with AJAX one bit!

 

...This thread got moved here, that was the first I'd ever heard of AJAX... did some background reading on it, sounds quite interesting, but considering I'm not a web programmer (don't really want to be either) I'm using PHP because its free and easy.

 

 

What I'm looking to do is to have a HTML webpage (generated by php) that has a button "Start" on it, when the user clicks this start button, the php script does a shell_exec() command and runs a PERL script that I wrote to auto-configure test devices (at least 8 are connected to the host machine).

 

Trouble is, the script takes about 5-10 minutes to complete, so every time I run the script from PHP I get:

 

Fata Error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\php\config.php on line 167.

 

 

Where the script has taken a long time to execute!

 

Any ideas how I get around this?

Link to comment
Share on other sites

Increase the max execution time in your php.ini to longer (this isn't really recommended though)

 

Optimize your script to go faster (what the heck are you doing that takes 10 minutes?!?)

 

Tell the person making the request that they'll have to wait, but they WILL be notified when the script is complete (simplest method.)

 

And btw, this isn't AJAX, as far as I know.  AJAX stands for Asynchronous Javascript And XML, it's using Javascript, a client side scripting language, to run php files, which are server side.  This allows you to run a request on a page and update that page with new information without reloading that page.  But what you're doing isn't AJAX.

Link to comment
Share on other sites

The script takes 10 minutes because it executes an external PERL script that

 

- Erase flash (takes about 10seconds)

- Flash firmware loader (takes about 15seconds)

- Flash firmware stack (takes about 30seconds)

- Merge PSData (takes about 10 seconds)

 

Do the above for each connected device; there are 8 devices connected to the host machine.

 

 

By the time the PERL script completes and returns its output (success/failure messages for each of the above for each device) the execution warning comes up.

 

 

Not fussed about security because its a private password protected machine behind firewalls and proxy, used by 4 test engineers, I setup WAMP so it runs in offline mode (i.e. no external machine can query the webserver) so security is not an issue.

 

Thanks for the php.ini stuff... I'll just write a message on the screen to warn it takes a long time to complete!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.