Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-04-09
3
Medium Priority
?
822 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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

618 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