从chrome扩展发送https到http的请求 [英] sending request from https to http from chrome extension
问题描述
你好,我有一个奇怪的问题,从https站点发送到http站点的请求由谷歌浏览器扩展..
Hello all i am having a strange issue with sending a request from https site to http site by google chrome extension..
jquery .js:6个混合内容: https://www.google.co。 in / webhp?hl = en '是通过HTTPS加载的,但请求一个不安全的XMLHttpRequest端点' http:// IP /统计/ search.php中?关键字=苹果。此请求已被阻止;该内容必须通过HTTPS提供。
jquery.js:6 Mixed Content: The page at 'https://www.google.co.in/webhp?hl=en' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://ip/stats/search.php?keywords=apple'. This request has been blocked; the content must be served over HTTPS.
这是我的代码,它被注入到网站...
this is my code which is injected to the site ...
$(document).ready(function(){
$('input[name=q]').keydown(function(e) {
if (e.keyCode == 13) {
v = $(this).val();
v=encodeURI(v);
$.ajax({
type: 'POST',
url: 'http://myipaddress/stats/search.php?keywords='+v,
data:{'search':v},
success: function(data){
//something....
}
});
}
});
});
Manifest.json
Manifest.json
{
"name": "Ads",
"version": "0.0.1",
"manifest_version": 2,
"description": "Injecting stuff",
"background":
{
"scripts": ["jquery.js","background.js"]
},
"browser_action": {
"default_title": "Inject!"
},
"permissions": [
"https://*/*",
"http://*/*",
"tabs"
],"content_scripts" : [
{
"js": ["jquery.js", "inject.js"],
"matches": ["*://*/*"]
}
]
}
推荐答案
如果由于页面原点而无法从内容脚本发出请求,请将其委托给后台脚本。
If you can't make a request from the content script due to the page's origin, delegate that to the background script.
发送消息到后台脚本以指示它发出请求,然后返回响应。记得从处理程序中返回返回true
,以表明您将以异步方式响应。
Send a message to the background script to instruct it to make a request, then return the response. Remember to return true
from the handler to indicate that you will respond asynchronously.
这篇关于从chrome扩展发送https到http的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!