Why JS is not working in PHP?
js file IS your jQuery file and you are adding your code to the top of the file, reason if you add the code into the document itself it DOES work. If that is the case then move your code to the end of the script. js file. OR you can make a separate file for your custom code and load it after the jQuery file.
Use AJAX to call a PHP script.
What are the functions of PHP?
PHP functions are similar to other programming languages. A function is a piece of code which takes one more input in the form of parameter and does some processing and returns a value.