Serve with php dev server:
$ cd /to/where/this/folder/is
$ php -S localhost:8000
Open browser to localhost:8000
View browser dev console with F12 in most browsers
PS: This code is not writen with good PHP or javascript (or even HTML), and only serves as a example.