I have file called functions.js included in page. I have there line:
ajaxRequest.open("GET", "save.php?json=" + jsonstring + "&rand=" + rand, true);
How to call php method by ajaxRequest? I also want to call this by php function from class (for example save($json, $rand))
Pseudo code:
ajaxRequest.callPhpFunction( function{ Class::save($json, $rand) } )
Maybe XAJAX (http://www.xajax-project.org/) is solution?
Your XHR (XML Http Request) makes an HTTP Request. This is the only way your JavaScript and your PHP will communicate (we do not talk about sockets here).
YOU have to code your back-end to do the good action when an URL is called, and seeing what you want to achieve, you maybe want to take a look at the REST method which approximately correspond to want you are looking for.