我在我的页面中使用jQuery。我导入了以下内容:为什么我在jQuery中遇到Uncaught类型的错误?
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="js/cookie.jquery.js"></script>
更改了Cookie插件的名称,因为我的TomCat服务器阻止了原始名称。我在控制台中收到以下错误,并且我的jQuery代码不工作!为什么我看到这个?
Uncaught TypeError: Object function (selector, context) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init(selector, context, rootjQuery);
} has no method 'cookie' AlertConfiguration.jsp:92
这是我的jQuery:
if($.cookie('remember_select') != null) {
$('.XCONPVAL option[value="' + $.cookie('remember_select') + '"]').attr('selected', 'selected');
$('.limitemailalertvalue option[value="' + $.cookie('remember_select') + '"]').attr('selected', 'selected');
$('.siteID1 option[value="' + $.cookie('remember_select') + '"]').attr('selected', 'selected');
$('.groupID1 option[value="' + $.cookie('remember_select') + '"]').attr('selected', 'selected');
$('.divisionID1 option[value="' + $.cookie('remember_select') + '"]').attr('selected', 'selected');
}
$('.select_class').change(function() {
$.cookie('remember_select', $('.XCONPVAL option:selected').val(), { expires: 90, path: '/'});
$.cookie('remember_select', $('.limitemailalertvalue option:selected').val(), { expires: 90, path: '/'});
$.cookie('remember_select', $('.siteID1 option:selected').val(), { expires: 90, path: '/'});
$.cookie('remember_select', $('.groupID1 option:selected').val(), { expires: 90, path: '/'});
$.cookie('remember_select', $('.divisionID1 option:selected').val(), { expires: 90, path: '/'});
});
这是我的文件夹层次。我有我的js文件在js文件夹中。我的JSP在jsps文件夹中。
你确定你的cookie插件的路径是正确的吗? – Felix
您的js文件'cookie.jquery.js'未正确加载,可能存在一些路径问题。 – Jai
@Felix看到我编辑的帖子。我包括我的文件夹层次结构 –