By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,342 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

PHP and Javascript question

P: n/a
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?
Aug 25 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Anic297 wrote:
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.
js*******@attglobal.net
==================

Aug 25 '08 #2

P: n/a
Jerry Stuckle a écrit:
Anic297 wrote:
>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.
Aug 25 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.