1
我正在做一個擴展名爲自動登錄到wifi,我使用AJAX做post請求,但是當我檢查pop的網絡時,它沒有發送POST請求,而只是顯示正在加載的彈出文件,並且一個jquery-1.10.1.min.map GET失敗。 這裏是我的popup.html:Jquery被導入但AJAX不工作?
<!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'
}
});
});
爲什麼不使用而是提交? – anand4tech
也許與同源政策有關? –