My javascript file:
var ms = 3000;
$.get("curl.php", { test: ms } );
My curl.php:
$ms = $_GET("test");
echo $ms;
Firefox firebug says:
Fatal error: Function name must be a string in
C:\Users\Jansu\Documents\workspace\php\curl.php on line 2
what could be the problem?
Even better would be when the javascript and php code is in the same file, so I don’t have to post/get anything. Just somehow pass javascript to php.
You want
[], not()(docs):Re your edit:
Even if they’re in the same file, they’re executed in completely different places. The JavaScript is executed on the client, the PHP is executed on the server. To get data from the client to the server, it has to be sent there. Ajax (the way you did it) is the primary way you do that without causing a full page refresh, so you’re on the right track.