Please help clear the cobwebs in my mind?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Yep - this is a PHP question.  Or maybe an HTML question.  Or even a
javascript question.  At this point I don't know.  What I do know is
that I'm completely frustrated so excuse my tone.

Here's what I have and what its doing (or NOT).   In a working web
page written in PHP I am reading in a purchase screen that contains a
form with all the required information.  When the submit button is
clicked I wish to replace the element on the screen that contains all
the information and replaces it with a Please wait . . . message and
animated gif.   The way I approached this first was to extract the
elements from the form in my php program and just prior to call on the
payment service I output a page with the please wait info.  Then when
control came back from the payment service I output the payment
complete page.   While it worked the way it should the payment
completed screen was appearing below the please wait screen even
though all the heading items were resent.

So I needed another way to intervene.  I created a javascript function
that used a getelementbyid referencing the desired div and set it
equal to the html code containing the please wait info.

This seemed to replace the div content as expected.  However, control
NEVER gets back to the php program for further processing.  I then
tried changing what the div encapsulated, etc, etc.

I'm kind of out of ideas at this time or burned out most of my gray
cells or both.

So, as the actual code is irrevelent can anyone shed some ideas as to
how and/or what I need to do to make this happen.   My original
thought was that this should be really simple.  Yet I'm banging my

Thanks for any suggestions provided.   Now back to the ice packs.

Re: Please help clear the cobwebs in my mind?

Quoted text here. Click to load it

Well, why should it? When you submit a form, you specify an action
which defines which page will load next. That page can contain some PHP
code if you wish. That PHP code executes completely before the page is
sent back to your browser.

To state it more completely, the page that is sent back is whatever is
generated as a result of that process. If the page is a mixture of HTML
and PHP, then the resulting page will be based on the HTML and whatever
output (using e.g. echo statements) the PHP generates. Once that has
happened, that is *it* as far as the PHP is concerned; it has done all
it is going to.

So, don't make the mistake of thinking that the PHP is sitting there
waiting for something; it isn't, because it's not running.

If you want more PHP processing you have to submit a form again or make
an ajax request.

"People don't buy Microsoft for quality, they buy it for compatibility
with what Bob in accounting bought last year. Trace it back - they buy
Microsoft because the IBM Selectric didn't suck much" - P Seebach, afc

Re: Please help clear the cobwebs in my mind?


Quoted text here. Click to load it

Have you considered using JQuery to handle the display changes?

Re: Please help clear the cobwebs in my mind?

On Sat, 25 Oct 2014 18:07:44 -0400, BobMCT wrote:

[tl:dr;] Q: How can I maintain control of what is displayed in the  
browser whilst waiting for a request from the server?

Quoted text here. Click to load it

Ans: Use ajax to send the request and wait for the response, and  
javascript to update the displayed content as required.

Denis McMahon,

Site Timeline