?
Solved

JavaScript to write and execute PHP script code to a div tag

Posted on 2009-04-09
3
Medium Priority
?
820 Views
Last Modified: 2012-08-13
I know php is server based and only executes when the page first loads (at run time)

my question is;
Can you use JavaScript to write and execute PHP script loaded from an external file?

this is what Ive tried;
<script type="text/javascript">
function showAreaOfTown(){
      var target = document.createElement( "script" );
      target.setAttribute( "src", "areaOfTown.php" );
      document.getElementById("areaOfTown").appendChild( target ); //the div tag
}
</script>

0
Comment
Question by:Cybervanes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Author Comment

by:Cybervanes
ID: 24112250
nobody has any ideas?
0
 
LVL 19

Assisted Solution

by:LordOfPorts
LordOfPorts earned 80 total points
ID: 24112346
One option would be to use AJAX http://www.w3schools.com/Ajax/ajax_intro.asp to call a specific PHP page which would perform a certain task and return a result which you can then assign to a DIV on the page, you could even pass code to the page through a URL parameter and then use the eval http://us2.php.net/eval function to execute the code.
0
 
LVL 2

Accepted Solution

by:
Cybervanes earned 0 total points
ID: 24168701
i decided to build a flash application instead. thanks.
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question