javascript - Where to put Js files in cakephp
I am wondering where to put my JS files so I don't make a complete mess out of my folders.
If I do a search on "Where to put Js files in cakephp" I get results of people explaining how to include a Js file into a page.
This JS file uses Ajax to post for example, books, to the database. So do I place this file in the controller folder, do I place it in Webroot/js/ under a certain folder or do I place it in the view folder?
Answer
Solution:
If you can't even answer that question for yourself, I highly recommend you to read the manual. If you already struggle with where to put the JS, you definitly will have trouble to figure out everything else as well.
JS goes to
/webroot/js
, images to/webroot/img
and make your guess where the CSS goes to.You should also read about the HtmlHelper to display files from the webroot.
But I personally would start here and do the tutorials.
Answer
Solution:
you should put your js file inside
webroot/js
folder. and then you can simply include the js with the function in the view.