我正在构建一个Chrome扩展,它应该向我的本地站点(Apache服务器HTTP站点)发送POST请求,但在尝试这样做时,我收到了一个错误。它将数据发送到https://,尽管我指定将其发送到http://
单击按钮时,我调用 * test 2 * 函数。它告诉 AJAX 数据需要发送到特定的URL。当我单击该按钮时,我得到这个错误SSL_ERROR
这是我的popup.js代码片段:
function test2(z,y) {
//makes sure that both parameters are present
if(z)
console.log(z );
if(y)
console.log(y );
//save data from POST in ff variable
ff = $("#frm");
//display all the information gathered from the extension popup, it works fine
console.log(ff);
console.log(ff.attr('id'));
console.log(ff.serialize());
//JQuery Ajax piece of code
$.ajax({
type: 'POST',
dataType:"json",
crossDomain: true,
//this is my local CakePHP website where I want to send data to
url: 'http://land.register/register',
data: ff.serialize(),
method:'post'
}).done(function( data ) {
if ( console && console.log ) {
console.log( "Sample of data:", data );
}
});}
我的 *land.register\webroot\ . httpaccess * 文件如下所示(我没有为本地网站启用HTTPS或提供证书)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
我的manifest.json看起来像这样:
{
"name": "KW Automatische",
"version": "0.1",
"manifest_version": 2,
"description": "Automatyzacja przeszukiwania KW",
"incognito": "spanning",
"content_security_policy": "script-src 'self' 'unsafe-inline' https://ajax.googleapis.com; object-src 'self'",
"browser_action": {
"default_icon": "icon-40@2x.png",
"default_popup": "popup.html",
"default_title": "Click here!"
},
"content_scripts": [
{
"matches": ["http://*/*"],
"js": ["contentScript.js","jquery.js"]
}
],
"background": {
"scripts": ["background.js"]
},
"icons": {
"16": "/images/book.png",
"32": "/images/book.png",
"48": "/images/book.png",
"128": "/images/book.png"
},
"permissions": [
"activeTab",
"http://*/*","*://*/*",
"notifications",
"storage"
]}
1条答案
按热度按时间zpgglvta1#
解决了这个问题,我需要从popup.html文件中删除
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
。