Click here to Skip to main content
15,920,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need a Javascript to call a PHP function , like that :
The problem i encounter is that the parameter id does not get passed .
Function MODIFICA($num) is defined in the same php file , and returns data using "print" ( this part works)

HTML
<p id="php_code"> Nothing yet.</p>

Java
function JSModify(id)
 {
document.getElementById("php_code").innerHTML="<?php MODIFICA("" + id + "");/???>";
return;
 }

PROBLEM :
Posted
Updated 17-Sep-11 4:39am
v5

You can't call PHP directly using Javascript. Javascript happens in the browser and PHP happens on the server, so by the time the Javascript is called the page has already been served.

If you really need to call PHP functions from Javascript you can use AJAX to make another request to the server.
 
Share this answer
 
oh , so that's why i always get the function MODIFICA(0) instead of my id ... tnx for help .
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900