【发布时间】:2026-01-29 15:05:01
【问题描述】:
我正在尝试创建 Google Chrome 扩展程序,但是当我提交表单时,我收到以下错误:
XMLHttpRequest cannot load http://www.domain.com/?i=ajax No "Access-Control-Allow-Origin".
我检查了“权限”下的扩展列表,我看到我的网站列在那里。
这是我的 manifest.json:
{
"name": "My Extension",
"version": "0.0.1",
"manifest_version": 2,
"browser_action": {
"default_icon": {
"19": "icons/19x19.png",
"38": "icons/38x38.png"
},
"default_title": "Quick Dashboard",
"default_popup": "popup.html"
},
"permissions": [
"http://www.domain.com/"
]
}
这是popup.html:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" src="jquery.js"></script>
<script src="main.js"></script>
<form id="url" method="post">
<label for="url">A bar</label>
<input id="urlname" name="url" type="text" value="" />
<input type="submit" value="Send" />
</form>
<div id="result"></div>
</div>
</body>
</html>
ajax.php 文件:
if($_POST){
die("success");
}
【问题讨论】:
标签: php jquery ajax google-chrome google-chrome-extension