【发布时间】:2013-11-22 14:01:58
【问题描述】:
我正在制作一个 chrome 扩展来自动登录到 wifi,我使用 AJAX 进行发布请求,但是当我检查弹出的网络时,它没有发送 POST 请求,它只显示正在加载的弹出文件,并且 jquery-1.10.1.min.map GET 失败。 这是我的popup.html:
<!doctype html>
<html>
<head>
<title>BCA Auto Login</title>
<script src="jquery.js"></script>
<script type="text/javascript" src="login.js"></script>
<style type="text/css">
body{
background-color: #2c3e50;
}
label{
color:#f1c40f;
}
</style>
</head>
<body>
<form method="POST" id="form">
<label>Enter username
<input id="username">
</label>
<br>
<label>Enter password
<input id="password" type="password">
</label>
<br>
<button type="submit" id="button">Submit</button>
</form>
</body>
</html>
这是我的 manifest.json:
{
"manifest_version": 2,
"name": "BCA Auto Login",
"description": "This extension automatically signs you into the BCA wifi",
"version": "1.0",
"permissions": [
"cookies",
"http://*/*",
"https://*/*"
],
"content_scripts": [{
"matches": ["http://*/*","https://*/*"],
"js": ["jquery.js","login.js"],
}],
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
}
}
这是我的 login.js:
$('#form').submit(function (event) {
event.preventDefault();
var url = 'https://ccahack.bergen.org/auth/perfigo_validate.jsp';
$.ajax({
type : 'POST',
url : 'http://whatsmywork.appspot.com/auth/perfigo_validate.jsp',
data : {
reqFrom: 'perfigo_simple_login.jsp',
uri: 'https://ccahack.bergen.org/',
cm: 'ws32vklm',
userip: 'IP',
os: 'MAC_OSX',
index: '4',
username: 'user',
password: 'pass',
provider: 'fds',
login_submt: 'Continue'
}
});
});
【问题讨论】:
-
为什么不使用 代替提交?
-
可能与同源政策有关?
标签: javascript jquery ajax google-chrome-extension