Skip to content Skip to sidebar Skip to footer

Calling A PHP Method From JavaScript

I was under the impression that since JavaScript is client-side and PHP is server-side, that it is impossible to call PHP from JavaScript; however, this code snippet works:

Solution 1:

Your PHP is being executed from the server side. Your PHP that you've embedded in the JavaScript never actually ends up rendering anything.

Test it by removing any calls to the otherCourse function, and you'll see that the query still runs.


Solution 2:

Your PHP executes on the server before that JavaScript even reaches the client.


Post a Comment for "Calling A PHP Method From JavaScript"