2011-02-07 65 views
1

我正在为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> 
+1

嗯,你能解释一下这些零件是如何连线的吗?显然,您使用两种不同的方式来执行请求(chrome built-in和jquery)。第一个片段与问题有关? – moritz 2011-02-07 22:46:37

回答

0

解决方案的问题是只使用HTTP来代替https,因为Meebo的的SSL证书是无效。