Hi @weissjl
If your code does not produce the desired result, you must debug your code line by line to find out where and what is going wrong.
Here is a simple thread about debugging in PHP:
http://stackoverflow.com/questions/888/how-do-you-debug-php-scripts
Next, you will need to debug your JS to make sure it is also working as expected. You can check your console log for any errors. Any JS error will prevent your JS code from working, so make sure you fix them all.
Good luck
Thanks
E