开发者

Function is not defined when appending a url parameter

I'm using Zend Framework and on one of my forms I have a ZendX JQuery form element. When I run the action that instantiates the form like this:

.../controller-name/action-name

the form element works fine.

But when I append a parameter to t开发者_如何学运维he url, i.e.

.../controller-name/action-name/parameter

the form element does not work and firebug tells me that '$ is not defined.'

Does anyone have any idea on what I should do?


It sounds like your jQuery include is relative, like this:

<script src="../js/jQuery.js" type="text/javascript"></script>

This depends on the page being at a certain level in the site, which is changing when you add another directory (as far as the browser is concerned). Whatever the path, make sure it's relative to the root of the site, for example:

<script src="/js/jQuery.js" type="text/javascript"></script>

Starting with a / means it's relative to the root of the site. Or, you can include it from a CDN, like this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜