将我的Chrome更新到版本37.0.2062.102 m后,我的扩展程序无法发送交叉来源请求。 错误消息是:No' Access-Control-Allow-Origin'标头出现在请求的资源上。
这里我给出了重现问题的源代码:
的manifest.json:
{
"name": "tes2",
"version": "0.1",
"description": ".",
"devtools_page": "main.html",
"manifest_version": 2,
"permissions": ["<all_urls>"],
"content_security_policy": "default-src 'self' chrome-extension-resource: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-eval'; connect-src *; frame-src *;"
}
main.html中:
<html>
<body>
<script src="js/addPanel.js"></script>
</body>
</html>
JS / addPanel.js:
chrome.devtools.panels.create(
'Session Management',
null, // No icon path
'Panel/sessionmanagement.html',
null);
面板/ sessionmanagement.html:
<html>
<head>
<script src="../lib/jquery-2.1.1.js"></script>
</head>
<body>
<button id="start-button">Start</button>
</body>
<script src="../js/tes.js"></script>
</html>
JS / tes.js:
$(window).load(function() {
$('#start-button').click(loginCallback);
});
var loginCallback = function () {
$.ajax({
type: "GET",
url: "http://google.com",
success: function(html, status, xhr){
alert(html);
}
});
}
LIB / jquery的-2.1.1.js: 请自行下载。