Include a page with onclick
I want to generate (or include) a php page by clicking on a link but does not change the page with a link type <a href="#" onclick="XxXx">
I used the Code:
PHP Code:
onclick = "open (<?php $pge = 'add_com'>)"
<script language="JavaScript">
<!--
function open (url) {
<?php
include ($pge.'.php');
?>
}
// -->
</script>
But it does not
Re: Include a page with onclick
Quote:
Originally Posted by
CodGuru
But it does not
Details? What does it display (error message), it does not produce the desired result, other (specify)?
Other:
JavaScript => Language executed later "client" (by the browser)
PHP => run server-side language.
What you want to look angrily at the AJAX
Re: Include a page with onclick
The problem is that you do not understand how PHP works. PHP is executed server side, and JavaScript client-side. So the browser can not interact with PHP (it is obliged to sent an additional request).
Re: Include a page with onclick
The answer is already given
Quote:
What you want to look angrily at the AJAX
With Ajax (Asynchronous JavaScript and XML), web applications can retrieve data from the server asynchronously in the background without interfering with the display and behavior of the existing page. Data is retrieved using the XMLHttpRequest object or through the use of Remote Scripting in browsers that do not support it. Despite the name, the use of JavaScript and XML is not actually required, nor do the requests need to be asynchronous.