2011-02-07 41 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證書是無效。