开发者

CakePHP is trying to load JS files in webroot/assets via AssetsController

I have some javascript and other files in webroot/assets. I 开发者_如何转开发want to keep them there rather than in webroot/js for reasons I can go into if necessary but won't here for brevity.

So home.ctp links to a couple of scripts in webroot/assets/js. However, it tries to route the requests through AssetsController, which doesn't exist. I can see in the Chrome JS debugger that CakePHP is printing the HTML, layout and all, for the missing controller error page.

Additionally, I'm getting the error "Resource interpreted as script but transferred with MIME type text/html."

I have this same set-up working fine on my local machine - home.ctp finds the JS files as expected. The problem is on my remote server.

Help much appreciated!

Thanks


Specify an absolute path: http://you.com/assets/js/yours.js.

Plain markup:

<script type="text/javascript" src="http://you.com/assets/js/yours.js"></script>

Or the HTML Helper in CakePHP:

<?php echo $this->Html->script('/assets/js/yours.js'); ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜