I have js file where i need to call the function defined in the php file to calculate the value and then move on to next step. Is this possible to do? I am not able to access the function of the php file from my script. Also is there some way around to include php file in a html page without changing the extention .html
I have js file where i need to call the function defined in the
Share
No, you cannot do that. PHP and Javascript do not execute in the same environment, nor at the same time.
PHP executes on YOUR web server (server-side) before the page is served up.
Javascript is executed on the CLIENT’s browser after the page has been served up.
To call a PHP function from javascript, you will need to make an AJAX call. This sends a value from the client side to the server side where it can be processed, and the response is then sent back to the client.