当我的PHP页面使用javascript文件(my_scripts.js)中的内容时,Google Developer Tools会显示以下错误:
"未捕获的ReferenceError:$未定义scripts.js:1(匿名函数)"
my_scripts.js的内容
$('a.button').click(function(){
window.location.href = "another_page.php";
});
Run Code Online (Sandbox Code Playgroud)
页面和脚本根据需要工作.单击元素链接到请求的页面,但错误就在那里.
1)导致错误的原因是什么?2)可以或应该忽略它吗?
我正在用PHP构建用户模块.它读取基于文本的用户类型,并分配一个数值来管理报表视图权限:
if ($usr_type == "Architect"){ $usr_rights = 0; }
if ($usr_type == "Director"){ $usr_rights = 1; }
if ($usr_type == "Manager"){ $usr_rights = 2; }
if ($usr_type == "Associate"){ $usr_rights = 3; }
if ($usr_type == "Assistant"){ $usr_rights = 4; }
if ($usr_type == "External"){ $usr_rights = 5; }
Run Code Online (Sandbox Code Playgroud)
有没有更简单,更优雅的方式来做到这一点?