[英]Uncaught ReferenceError: categoryID is not defined error
下面的代码引发Uncaught ReferenceError:categoryID未定义错误,这是什么问题?
function selectCategory(obj) {
var categoryId;
categoryId=obj.getAttribute("data-category-id");
if ((document.getElementById("sCategory").value) != categoryID)
{
document.getElementById("sCategory").value = categoryID;
$.fancybox.close(".category-selection-fancybox-popup");
$.cookie("categoryId", categoryID, { expires : 360 });
$('.search').submit();
} else {
$.fancybox.close(".category-selection-fancybox-popup");
}
}
变量在javascript中区分大小写。 实际上, JavaScript完全是区分大小写的语言。 您已经声明了像var categoryId;
这样的变量var categoryId;
在你if条件使用的是资本d在变量名的结束- > != categoryID
和$.cookie("categoryId", categoryID
为好。
JavaScript是区分大小写的语言。 因此,可能的原因是您在以下几行中将categoryId
称为categoryID
。
document.getElementById("sCategory").value = categoryID;
$.cookie("categoryId", categoryID, { expires : 360 });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.