You are here: Re: Loading a PHP file/code via Javascript. « PHP Programming Language « IT news, forums, messages
Re: Loading a PHP file/code via Javascript.

Posted by d on 11/18/22 11:41

"Simon" <spambucket@example.com> wrote in message
news:46re0iFcj4evU1@individual.net...
> Hi,
>
> Sorry for the cross posting, but I think it applies to both languages.
>
> As we all know, JavaScript is client side and php is server side, (the php
> code is 'allowed' to do stuff on the server that JavaScript cannot).
> The problem with php is that it timeout after a while, (and the user also
> has no clue as to what is going on for a long time).
> I need to run a script on the server that could take a very long time.
>
> So what I was thinking is mixing both JavaScript and PHP
> Something like,
>
> <script>
> var endvalue = 1000; /* some number that the server can calculate
> quickly */
> var i = 0
> while (i<=endvalue)
> {
> /**
> call a php file that will do some work
> somefunction.php?someNumber=i
> */
> }
> </script>
>
> That way the server does the work, while the client keeps it going.
> Ideally I would also get a return value/string from the php script.
>
> How could I achieve something like that?
>
> Many thanks in advance.
>
> Simon

I've done something similar to this myself :)

I found the best way to do it is to have your lengthy PHP script running in
a hidden iframe, occasionally spitting out chunks of javascript (in complete
<script> tags), and flushing the output after each tag is written. The
javascript can update a textual display, or a progress bar or whatever, on
the document holding the iframe. It's really simple to use, and very
effective.

dave

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация