我正在为Google Chrome编写插件,但问题是,我无法使用jQuery $ .get调用。控制台说:无法加载资源。
// popup.html
<script>
_get = function(url, callback) {
console.log("sending get");
chrome.extension.sendRequest({action:'get',url:url}, callback);
}
_get('https://www.meebo.com/mcmd/start.cgi?type=mobile&allowIPChange=true', function(data) {
alert(data);
});
</script>
// background.html
<script src="jquery.js"></script>
<script type="text/javascript">
function onRequest(request, sender, callback) {
if (request.action == 'getJSON') {
$.getJSON(request.url, callback);
}
if (request.action == 'ajax') {
$.ajax({
type : request.type,
url : request.url,
async : async,
success : callback
});
}
if (request.action == 'get') {
$.get(request.url, callback);
}
if (request.action == 'post') {
$.post(request.url, request.data, callback);
}
}
chrome.extension.onRequest.addListener(onRequest);
</script>
答案 0 :(得分:0)
问题的解决方案是仅使用http而不是https,因为meebo的ssl证书无效。