我正在尝试使用使用jQuery的外部javascript文件进行chrome扩展。但我一直在犯这个愚蠢的错误。
Screenshot of error in chrome inspector.
感谢任何帮助!
popup.js
$(document).ready(function() {
$.ajax({url: "http://www.google.com", success: function(result) {
$("#report-details").html(result);
}});
});
popup.html
<!doctype html>
<html>
<head>
<title>TEST</title>
<script src="popup.js"></script>
<script src='./js/jquery.min.js'></script>
<script src='./js/jquery.js'></script>
</head>
<body>
<h1>TEST</h1>
<div id="report-details">
</div>
</body>
</html>
的manifest.json
{
"manifest_version": 2,
"name": "my ext",
"description": "fun ext",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"activeTab"
],
"content_scripts": [
{
"matches": ["http://*/*","https://*/*"],
"js": ["js/jquery.min.js"]
}
]
}
非常感谢任何帮助。 (如果这是一个noob错误,我道歉)
答案 0 :(得分:3)
首先加载 Jquery插件,然后才能加载popup.js
<script src='./js/jquery.min.js'></script>
<script src="popup.js"></script>
注意:无需加载2个jquery插件