0

I am trying to invoke a php function from JS. php function:

function sayHi(){
debug_to_console("test");
}

I am running my site on local server so my address is like this: http://localhost:8888/

Jouba Ayedi
  • 51
  • 1
  • 1
  • 4
  • You must use AJAX for this. – Jay Blanchard Jun 01 '17 at 20:44
  • 1
    *sigh* Nonono. PHP runs before the page is sent to the browser. Javascript runs after. – aynber Jun 01 '17 at 20:45
  • As @JayBlanchard said, you will need to make an AJAX call to execute a PHP script via javascript. Most common JS libraries have simple wrapper functions to make AJAX calls. For example, [jquery has an AJAX function](http://api.jquery.com/jquery.ajax/). – RToyo Jun 01 '17 at 20:47

0 Answers0