1

I am trying to include a .js file I created by using this:

echo $this->Html->script('vote'); 

My file is in /js/vote.js

I load the website and I go to the sourcecode, I click on the .js script file to see what it is loading and what I find out is that that the is an error loading vote.js

When I try to access directly from the URL using:

http://localhost:8888/mysite/js/vote.js

I find this:


Error: JsController could not be found. Error: Create the class JsController below in file: app/Controller/JsController.php <?php class JsController extends AppController { } 

Then I created what it says, I get another error:


Missing Method in JsController Error: The action vote.js is not defined in controller JsController Error: Create JsController::vote.js() in file: app/Controller/JsController.php. <?php class JsController extends AppController { public function vote.js() { } } 

What's the problem? Why is it so complicate to load a .JS file?

I am just trying to make a button to vote on articles and I am driven crazy...

2
  • It definately shouldn't be a difficult task. There must be some form of glaring error (ie missing a js file...etc) or something wrong in the CakePHP setup like rewrite not working, or file structure off...etc Commented Dec 5, 2011 at 14:42
  • Rewrite is working in the page. But it seems like it doesn't allow me to see the .js file if there is not a view created for it. (as it happend with other actions) I don't get why. Commented Jan 17, 2012 at 18:47

2 Answers 2

5

Have you created a file called "vote.js" in your app/webroot/js folder?

Sign up to request clarification or add additional context in comments.

1 Comment

Ok, that's it. Thanks!! By the way. Why it takes it from webroot?? Should i put there all my css and js files? Why doesn't it take it from js folder, or lib..
0

you include it correctly!

my guess: mod_rewrite not on or some other wrong config setting

1 Comment

Finally i get it worked. I had to place it on webroot. Thanks anyway.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.