You are here: Re: php generate HTML, but being called by javascript « PHP Programming Language « IT news, forums, messages
Re: php generate HTML, but being called by javascript

Posted by Jerry Stuckle on 11/10/06 21:15

c.l.rogers@cox.net wrote:
> I've been searching for few days trying to find an answer to my
> question... hopefully I ofund the right place to help me out!
>
> What I am trying to do is use javescript inside column of a <table>
> tag, to call a php file that will fill in the contents for my column
> and the html page will then finish loading... For example:
>
>
> <html>
> <tr>
> <td valign="top">
> <script type="text/javascript"
> src="dir/external.php?"></script>
> <script language="" type="text/javascript">
> <!--
> for (x = 0; x < 10; x++)
> {
> document.writeln("<a href=data returned from php call >
>
> </a>");
> }
> //-->
> </script>
> </td>
> </tr>
> </html>
>
>
> To give you all a background of what I am doing is, I am using
> MagpieRSS to parse out my XML file and I would like to have my php file
>
> generate an array of data from the parsed file to return back to the
> javascript in my HTML file and use it to fill in my column... make
> sense?
>
>
> Thanks in advance for any help!
>
>
> Regards,
>
>
> Me
>

You can't do it like you want. PHP is executed on the server, before
the page loads. Javascript is executed on the client, after the page
loads. By the time your javascript starts executing, all of your PHP
code has been executed.

Two ways to go about this - either write all the data to the page as
javascript code (i.e a javascript array), or use AJAX to call PHP back
on the server.

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

 

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

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