Connecting Tech Pros Worldwide Forums | Help | Site Map

PHP and Javascript question

Anic297
Guest
 
Posts: n/a
#1: Aug 25 '08
Hi,

In my php script, I often use the
echo "<script>alert('".$randnums."')</script>";
command to debug something. It can happen in a loop, also.

I have no way to tell, so I ask here: since php is executed on the
server and JavaScript is executed on the client, when such an alert is
displayed, the code continues on the server side (php) so it's clearly
possible that the php code has finished while the first alert is being
displayed, or is it more complex?

Jerry Stuckle
Guest
 
Posts: n/a
#2: Aug 25 '08

re: PHP and Javascript question


Anic297 wrote:
Quote:
Hi,
>
In my php script, I often use the
echo "<script>alert('".$randnums."')</script>";
command to debug something. It can happen in a loop, also.
>
I have no way to tell, so I ask here: since php is executed on the
server and JavaScript is executed on the client, when such an alert is
displayed, the code continues on the server side (php) so it's clearly
possible that the php code has finished while the first alert is being
displayed, or is it more complex?
>
The code on the server side has almost ALWAYS finished before the alert
has been displayed. The only exception would be if you had something
running a lot time on the server side and enough of the buffers had been
flushed that the javascript got executed. And while that would be very
rare, it could happen.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Anic297
Guest
 
Posts: n/a
#3: Aug 25 '08

re: PHP and Javascript question


Jerry Stuckle a écrit:
Quote:
Anic297 wrote:
Quote:
>Hi,
>>
>In my php script, I often use the
>echo "<script>alert('".$randnums."')</script>";
>command to debug something. It can happen in a loop, also.
>>
>I have no way to tell, so I ask here: since php is executed on the
>server and JavaScript is executed on the client, when such an alert is
>displayed, the code continues on the server side (php) so it's clearly
>possible that the php code has finished while the first alert is being
>displayed, or is it more complex?
>>
>
The code on the server side has almost ALWAYS finished before the alert
has been displayed. The only exception would be if you had something
running a lot time on the server side and enough of the buffers had been
flushed that the javascript got executed. And while that would be very
rare, it could happen.
Thank you.
Closed Thread