You can call php functions with javascript and get responce back in javascript with jAPI Direct class.
jAPI Direct contains PHP and JavaScript script that enables you to call PHP methods direct from JavaScript just by typing their names.
For example you can call PHP method that looks like this:
class MySimpleMath {
public function Addition($firstParam, $seccondParam) {
$sum = $firstParam+$seccondParam; echo $sum;
}
}
...from JavaScript just with:
And you will have as a result: "3"
To use jAPI in your project you will have to fallow a few steps only.
First download jAPI project source from
this address.
Make sure that you included in your html page all scripts properly. You also have to include this two scripts in your html file: jAPI.js, jAPI-Remote.php.
jAPI-Remote.php actually can be any php script from which you want to use their server side methods.
You have to include jAPI-Core.php script in this file (jAPI-Remote.php) by adding this line of code at the beggining of your script:
include("httpHandler/jAPI-CORE.php");
And at the end of your script you will have to create a new instance of jAPI Base Class like this:
//all classes names comma separated as jAPIBaseClass parameter which you want to use
new jAPIBaseClass('YourClass,AnotherClass');
So, that's it!